you can use preg_replace (); when it finds a match in your text, you can put a div with a highlight class around the corresponding word. Then you added the background color and border to the selection class to highlight it.
preg_replace expect 3 parameters;
- the first is what you are looking for.
- the second is what should be changed to
- The line of text that it should search for and replace from
eg,
<div class="center_div">
<table>
<caption>Search Results</caption>
<?php while ($row= mysql_fetch_array($result)) { ?>
<?php $arabic = preg_replace("/".$search_result."/", "<div class='highlight'>".$search_result."</div>", h($row['cArabic'])); ?>
<tr>
<td style="text-align:right; font-size:15px;"><?php $arabic ?></td>
<td style="font-size:16px;"><?php h($row['cQuotes']) ?></td>
<td style="font-size:12px;"><?php h($row['vAuthor']) ?></td>
<td style="font-size:12px; font-style:italic; text-align:right;"><?php h($row['vReference']) ?></td>
</tr>
<?php } ?>
</table>
</div>
, cQuotes, vAuthor vReference.