i have a similar problem, so perhaps we have a similar solution. I'm attempting to highlight the results of my search.
This code works perfectly, if i have only one search word, or two contigious words. However, if the search returns the two words separately (as often happens), then i get no result in my highlighting.
Also if i use any advanced search features such as prepending a "+" or a "-", the the highlighting is not there.
here is my code and hopefully someone can tell me where i'm wrong.
$srch=mysql_real_escape_string($_POST['search']);
if ($srch!==""){
$sql = "select *, match(synopsis) against('$srch') as relevance from cases where match(synopsis) against('$srch' IN BOOLEAN MODE) order by relevance desc";
$result = mysql_query($sql);
if(!$result){
echo "No matches for ".$srch.".";
}else{
while($r = mysql_fetch_array($result)){
echo $r[case_id]."  ";
echo '<a href="buttons.php?case_id='.$r[case_id].'&mode=add"><img src="/images/add.gif" border="0" alt="Make payments with PayPal - it\'s fast, free and secure!"></a><br>';
echo "<b>".$r[headline]."</b><br>";
$str = $r[synopsis];
$str = eregi_replace($srch,'<span style="background-color:#8AB0FF">'.$srch.'</span>', $str);
echo $str."<br><br><br>";
}
}
}
thanks!