View Full Version : highlighting search results with variations

ali haydar
10-21-2012, 04:33 PM
hi everybody..

there is an arabic query script you can test online at:

it searches arabic words with variations..

the files available at:

i want to use it and want to highlight keywords in the results..

to do this, i added these two lines to query.php fıle,

$searchvalue = $row['headline'];
$searchvalue = preg_replace("/\p{L}*?".preg_quote($keyword)."\p{L}*/ui", "<b>$0</b>", $searchvalue);

after this line on the file:

$headline = $row['headline'];

and changed this line in the file:

echo"<tr bgcolor=\"$bg\"><td><font size=\"2\">$headline</font></td></tr>";

with this:

echo"<br><tr bgcolor=\"$bg\"><td><font size=\"2\">$searchvalue</font></td></tr><br>";

now it highlights the keyword in the results, but only if it is an exact match, so if i search "ايضا" with alef, but in the database it is written "أيضا" with hamza, it doesn't highlight it, even though it finds it..
[basically it finds "hellö" if you search "hello", but only highlights it you search exactly "hellö"]

any help much appreciated..