Hi James
I'll paste the code I use..
$string = search string entered in the text box.
#############################################################
// REPLACE SPACES FOR MULTIWORD SEARCH
$string = str_replace(" ","%",$string);
$db->query("SELECT title,description FROM files WHERE (title LIKE
'%$string%') || (description LIKE '%$string%')");
// SPLIT THE SEARCH INTO PARTS FOR HIGHLIGHTING
$bg = explode("%",$string);
while($db->next_record())
{
$title = $db->f("title");
$des = $db->f("description");
for($z=0; $z < count($bg); $z++)
{
// reset the array if it's at the end
if(next($bg) == false)
{
reset($bg);
}
$bgstring = current($bg);
$title = preg_replace("/($bgstring+)/ie", "'<span
class=message>\\1</span>'", $title);
$des = preg_replace ("/($bgstring+)/ie", "'<span
class=message>\\1</span>'", $des);
}
echo $title.NL;
echo $des.NL.NL;
}
###############################################################
The above code works as expected....except if I search for span and say
class;
now this will highlight span in the search string found from the database
but on the second run ie. hightlighting class, it will re-highlight the
<span> in the span tags from the original pass.
Do you get what I mean??
preg_replace is used to keep the original case of the results as it's a case
insensitive search
I need to be able to replace only result that aren't enclosed in a class tag
Cheers
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]