How do I highlight keywords in search result?
Here's an example of my code:
<?php
$mysql = new mysqli($host,$username,$password,$database);
$keyword = 'racing';
$query = $mysql->query("SELECT * FROM products WHERE title LIKE '%$keyword%' OR description LIKE '%$keyword%'");
while($result = $query->fetch_object())
{
echo '<p>';
echo $result->title.'<br />';
echo substr($result->description,'0','256');
echo '</p>';
}
?>
In this code, the keyword is racing
, so I would like all the racing
in the search result highlighted.