highlighting Search Results

From: Date: Mon, 06 May 2002 11:26:34 +0000
Subject: highlighting Search Results
Groups: php.general 
Request: Send a blank email to php-general+get-96237@lists.php.net to get a copy of this message
Hi all, I have a mySQL database running with PHP4. I have constructed a search form ($searchSite) which returns results in a results page & now I want to have the word that was entered in the search form highlight in the results page. eg User enters a search for products using the word " gardening" Results page might return: "this shovel is a great gardening tool" and "to be a expert in gardening, you will need"...............I want the word gardening to be bold wherever it is displayed. My results page has the following code to display search results: BTW it works like a dream...I just want to jazz it up a bit. <? $result = mysql_query("SELECT * FROM products WHERE Description LIKE '%$searchSite%' OR Keywords LIKE '%$searchSite%' OR CatName LIKE '%$searchSite%' "); blah blah blah while ( $row = mysql_fetch_array($result) ) { echo("<tr bgcolor='#FFFFFF'>"); echo("<td width='93'><div align='center'><font size= '2' face = 'Arial,Helvetica,Sans serif'>" . $row["Description"] . "</td>"); echo("<td width='93'><div align='center'><font size= '2' face = 'Arial,Helvetica,Sans serif'>" . $row["ProductName"] . "</td>"); echo("<td width='93'><div align='center'><font size= '2' face = 'Arial,Helvetica,Sans serif'>\$" . $row["RetailPrice"] . "</td>"); ?> How do I do this to highlight my search words? Thanks, any ideas much appreciated by this PHP newbie. DC

« previous php.general (#96237) next »