title: Displaying message when no results found in PHP MySQL search
body: <p>I have a PHP search script which queries a MySQL database. Currently, when no results are displayed the script shows and error. How can I make it display a message like "No Results were found" when nothing is returned?</p>
  
  <p>My PHP script is:</p>
  
  <pre><code>&lt;?php
  
  mysql_connect("localhost","username","password");
  mysql_select_db("database");
  
  if(!empty($_GET['q'])){
  $query=mysql_real_escape_string(trim($_GET['q']));
  $searchSQL="SELECT * FROM links WHERE `title` LIKE '%{$query}%'  LIMIT 8";
  $searchResult=mysql_query($searchSQL);
  
  while ($row=mysql_fetch_assoc($searchResult)){
      $results[]="&lt;div class='webresult'&gt;&lt;div class='title'&gt;&lt;a href='{$row['url']}'&gt;{$row['title']}&lt;/a&gt;&lt;/div&gt;&lt;div class='desc'&gt;{$row['description']}&lt;/div&gt;&lt;div class='url'&gt;{$row['url']}&lt;/div&gt;&lt;/div&gt;";
  }
  
  echo implode($results);
  }
  
  ?&gt;
  </code></pre>