Menu

#32 BUG in PowerSearch

PCG v3.0
open
nobody
None
5
2004-12-06
2004-12-06
Anonymous
No

ote on the EDIT and DELETE some separator was missed in the
HTML code generation that displays part of the Fiel Data instead of
only the EDIT and DELETE options. Look at the URL to follow the
code in the page generated to diplays the Power Search.

regards

Discussion

  • Nobody/Anonymous

    Acrobat showing Bug

     
  • Nobody/Anonymous

    Logged In: NO

    this code is creating the EDIT and DELETE tags problem when this script
    generates de code searchUsers.php

    function highlightSearchTerms($fullText, $searchTerm,
    $bgcolor="#FFFF99")
    {
    if (empty($searchTerm))
    {
    return $fullText;
    }
    else
    {
    $start_tag = "<span style=\"background-color: $bgcolor\">";
    $end_tag = "</span>";
    $highlighted_results = $start_tag . $searchTerm . $end_tag;
    return eregi_replace($searchTerm, $highlighted_results,
    $fullText);
    }
    }

    $fullText has incorrect values and hence generatin ginvalid output.

    searchUsers.php where "Users" is the table in question.

    You should also ad the capability of marking a field as password when
    generating forms from databases, this way these marked field would be
    either ignored or displayed Blank on the views of tables forms.

    This is a test Database

     
  • Nobody/Anonymous

    Logged In: NO

    this only happens when a string for search (keyword) matches a search
    pattern, otherwise works fine

     
  • Nobody/Anonymous

    Logged In: NO

    to fix this, in the while loop, do not overwirte the Original Field Variable,
    why don't you generate an alternate field name for the lists and use the
    original fieldname for the EDIT and DELETE, this should not be complex.

    The problem is that you reuse $this<fieldname> and if you typed a
    matching keyword, this will be "highlighted" and returned with the
    Highlight to the field variable, hence the error in the edit and Delete
    options:

    <a href="editUsers.php?fullnameField=<? echo $thisFullname; ?
    >">Edit</a>

    The use of $thisFullname here is incorrect if there was a matching
    Keyworh, $thisFullname will contain the "<span>" highlight caracters
    hence changing the actual string from the FullName to the Highlighted
    HTML fullname.

    Maybe you can generate the code for the list view (data) with
    $this<fielname>Hi for highlighted and leave the original
    $this<fieldname> for the Edit and Delete options !

    <?
    $highlightColor = "#FFFF99";

    while ($i<$numberOfRows)
    {

    if (($i%2)==0) { $bgColor = "#FFFFFF"; } else { $bgColor =
    "#C0C0C0"; }

    $thisFullname = MYSQL_RESULT($result,$i,"fullname");
    $thisUsername = MYSQL_RESULT($result,$i,"username");
    $thisPassword = MYSQL_RESULT($result,$i,"password");
    $thisStatus = MYSQL_RESULT($result,$i,"status");
    $thisLevel = MYSQL_RESULT($result,$i,"level");
    $thisFullname = highlightSearchTerms($thisFullname, $thisKeyword,
    $highlightColor);
    $thisUsername = highlightSearchTerms($thisUsername,
    $thisKeyword, $highlightColor);
    $thisPassword = highlightSearchTerms($thisPassword, $thisKeyword,
    $highlightColor);
    $thisStatus = highlightSearchTerms($thisStatus, $thisKeyword,
    $highlightColor);
    $thisLevel = highlightSearchTerms($thisLevel, $thisKeyword,
    $highlightColor);

    ?>
    <TR BGCOLOR="<? echo $bgColor; ?>">
    <TD><? echo $thisFullname; ?></TD>
    <TD><? echo $thisUsername; ?></TD>
    <TD><? echo $thisPassword; ?></TD>
    <TD><? echo $thisStatus; ?></TD>
    <TD><? echo $thisLevel; ?></TD>
    <TD><a href="editUsers.php?fullnameField=<? echo $thisFullname;
    ?>">Edit</a></TD>
    <TD><a href="confirmDeleteUsers.php?fullnameField=<? echo
    $thisFullname; ?>">Delete</a></TD>
    </TR>
    <?
    $i++;

    } // end while loop
    ?>

     
  • Nobody/Anonymous

    Logged In: NO

    generating this code will correct the output:

    while ($i<$numberOfRows)
    {

    if (($i%2)==0) { $bgColor = "#FFFFFF"; } else { $bgColor =
    "#C0C0C0"; }

    $thisFullname = MYSQL_RESULT($result,$i,"fullname");
    $thisUsername = MYSQL_RESULT($result,$i,"username");
    $thisPassword = MYSQL_RESULT($result,$i,"password");
    $thisStatus = MYSQL_RESULT($result,$i,"status");
    $thisLevel = MYSQL_RESULT($result,$i,"level");
    $thisFullnameHi = highlightSearchTerms($thisFullname,
    $thisKeyword, $highlightColor);
    $thisUsernameHi = highlightSearchTerms($thisUsername,
    $thisKeyword, $highlightColor);
    $thisPasswordHi = highlightSearchTerms($thisPassword,
    $thisKeyword, $highlightColor);
    $thisStatusHi = highlightSearchTerms($thisStatus, $thisKeyword,
    $highlightColor);
    $thisLevelHi = highlightSearchTerms($thisLevel, $thisKeyword,
    $highlightColor);

    ?>
    <TR BGCOLOR="<? echo $bgColor; ?>">
    <TD><? echo $thisFullnameHi; ?></TD>
    <TD><? echo $thisUsernameHi; ?></TD>
    <TD><? echo $thisPasswordHi; ?></TD>
    <TD><? echo $thisStatusHi; ?></TD>
    <TD><? echo $thisLevelHi; ?></TD>
    <TD><a href="editUsers.php?fullnameField=<? echo $thisFullname;
    ?>">Edit</a></TD>
    <TD><a href="confirmDeleteUsers.php?fullnameField=<? echo
    $thisFullname; ?>">Delete</a></TD>
    </TR>
    <?
    $i++;

    } // end while loop

    note the "Hi" added to the List display, maintaining the original
    $this<fieldname> intact for the EDIT and DELETE options.

    It works and it should not be a big a deal to generate this minor change
    in the code generation routine.

    regards

     
  • Nobody/Anonymous

    Logged In: NO

    generating this code will correct the output:

    while ($i<$numberOfRows)
    {

    if (($i%2)==0) { $bgColor = "#FFFFFF"; } else { $bgColor =
    "#C0C0C0"; }

    $thisFullname = MYSQL_RESULT($result,$i,"fullname");
    $thisUsername = MYSQL_RESULT($result,$i,"username");
    $thisPassword = MYSQL_RESULT($result,$i,"password");
    $thisStatus = MYSQL_RESULT($result,$i,"status");
    $thisLevel = MYSQL_RESULT($result,$i,"level");
    $thisFullnameHi = highlightSearchTerms($thisFullname,
    $thisKeyword, $highlightColor);
    $thisUsernameHi = highlightSearchTerms($thisUsername,
    $thisKeyword, $highlightColor);
    $thisPasswordHi = highlightSearchTerms($thisPassword,
    $thisKeyword, $highlightColor);
    $thisStatusHi = highlightSearchTerms($thisStatus, $thisKeyword,
    $highlightColor);
    $thisLevelHi = highlightSearchTerms($thisLevel, $thisKeyword,
    $highlightColor);

    ?>
    <TR BGCOLOR="<? echo $bgColor; ?>">
    <TD><? echo $thisFullnameHi; ?></TD>
    <TD><? echo $thisUsernameHi; ?></TD>
    <TD><? echo $thisPasswordHi; ?></TD>
    <TD><? echo $thisStatusHi; ?></TD>
    <TD><? echo $thisLevelHi; ?></TD>
    <TD><a href="editUsers.php?fullnameField=<? echo $thisFullname;
    ?>">Edit</a></TD>
    <TD><a href="confirmDeleteUsers.php?fullnameField=<? echo
    $thisFullname; ?>">Delete</a></TD>
    </TR>
    <?
    $i++;

    } // end while loop

    note the "Hi" added to the List display, maintaining the original
    $this<fieldname> intact for the EDIT and DELETE options.

    It works and it should not be a big a deal to generate this minor change
    in the code generation routine.

    regards

     

Log in to post a comment.