title: Highlight search text in mysql php search
body: <p>hi this is the script i have, it works well to search my database.
  i have a <strong>form.html</strong> where the user inputs the keyword in a search box.</p>
  
  <pre><code>&lt;form method="get" action="form.php"&gt;
  &lt;input type="text" name="searchterm" title="Enter your search term here" value="Enter your search term here" class="searchbox" /&gt;
  &lt;input type="submit" name="search" title="Search Now! "value="Search" class="searchbutton" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>i would like to highlight the search text in the result.</strong> </p>
  
  <p>many thanks </p>
  
  <p><strong>form.php</strong></p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Search&lt;/title&gt;
  &lt;link href="default.css" rel="stylesheet" type="text/css" media="screen" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;?php
  
  // include MySQL-processing classes
  
  require_once 'mysql.php'; 
  
  try{
  
  // connect to MySQL
  
  $db=new MySQL(array('host'=&gt;'','user'=&gt;'','password'=&gt;'','database'=&gt;''));
  
  $searchterm=$db-&gt;escapeString($_GET['searchterm']);
  
  $result=$db-&gt;query("SELECT * FROM BookPage WHERE (PageText) like \"%$searchterm%\" ");
  
  if(!$result-&gt;countRows()){
  
  echo '&lt;div class="maincontainer"&gt;&lt;h2&gt;No results were found. Go back and try a new search.&lt;/h2&gt;&lt;/div&gt;'."n";
  
  }
  
  else{
  
  // display search results
  
  echo '&lt;div class="maincontainer"&gt;&lt;h2&gt;Your search criteria
  returned '.$result-&gt;countRows().' results.&lt;/h2&gt;'."n";
  
  while($row=$result-&gt;fetchRow()){
  
  echo '&lt;div class="rowcontainer"&gt;&lt;p&gt;&lt;strong&gt;Book Id:
  &lt;/strong&gt;'.$row['BookId'].'&lt;p&gt;&lt;p&gt;&lt;strong&gt;Page Id:
  &lt;/strong&gt;'.$row['PageId'].'&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Page Text:
  &lt;/strong&gt;'.$row['PageText'].'&lt;/p&gt;&lt;/div&gt;'."n"; 
  
  }
  
  }
  
  echo '&lt;/div&gt;';
  
  }
  
  catch(Exception $e){
  
  echo $e-&gt;getMessage();
  
  exit();
  
  }
  
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>