> The input from the search form is $searchtext. The Returned
> Search data is
> $searchdata.
>
> <?
>
> $sql = "SELECT searchdata FROM table WHERE searchdata LIKE
> '%$searchtext'";
> $result = @mysql_query($sql, $connection)
> or die (mysql_error());
>
> $num = mysql_num_rows($result);
>
> $x = 0;
>
> if ($num == 0) {
> echo "No results";
> } else {
>
> while($row = mysql_fetch_array($result)) {
> $searchdata = $row['searchdata'];
>
> $x++;
>
> $searchdata = eregi_replace("$searchtext", "<font
> color=\"#FF0000\">$searchtext</font>", $searchdata);
>
> echo "$x. $searchdata";
>
> }
>
> }
>
> ?>
>
> Make sense? And does it help?
Hi James
Yes and no.
I've got it to do that but what if the user enters more than one word?
I need to be able to loop inside the while for each word to be able to
highlight it. I think!
The problem is if someone enters a word which is used within the
hightlighting code. ie. font in your example.
This would then hightlight this again and screw the resulting code.
M@
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]