title: missing data from mysql database
body: <p>I have a mysql database that is used by a php script to display data... the problem i have is, at what appears to be random occurrences it misses results and I can't see a pattern to establish why it might be doing it...</p>
  
  <p>all the data appears to be fine when i check the database.</p>
  
  <p>here is my initial search page</p>
  
  <pre><code>&lt;?php
  include 'connect.php';
  
  //set variable
  $option = '';
  
  // Get the county names from database - no duplicates - Order A-Z
  $query = "SELECT DISTINCT tradingCounty FROM offers ORDER BY tradingCounty ASC";
  
  // execute the query, $result will hold all of the Counties in an array
  $result = mysqli_query($con,$query);
  
  
   while($row = mysqli_fetch_array($result)) {
      $option .="&lt;option&gt;" . $row['tradingCounty'] . "&lt;/option&gt;";
  }
  
  
  
  
  echo "&lt;html xmlns='http://www.w3.org/1999/xhtml'&gt;";
  echo "&lt;title&gt;HSB - Latest Offers&lt;/title&gt;";
  echo "&lt;style type='text/css'&gt;;
  body {
      background-color: #FFF;
  }
  #wrapper {
      background-color: #FFF;
      height: auto;
      width: 1000px;
      margin-right: auto;
      margin-left: auto;
      font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id='wrapper'&gt;
    &lt;p&gt;&lt;img src='images/header.jpg' width='400' height='100' alt='header' /&gt;&lt;/p&gt;
    &lt;HR/&gt;
    Select an area from the menu below to view any offers in that area.
    &lt;form id='filter' name='filter' method='post' action='resultssimple.php'&gt;
          &lt;p&gt;&lt;label&gt;County&lt;/label&gt;&lt;/p&gt;
          &lt;select name='result' id='result'&gt;' . $option . '&lt;/select&gt;
          &lt;input name='' type='submit' /&gt;
          &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;";
  
  
  
  ?&gt;
  </code></pre>
  
  <p>and here is my results page</p>
  
  <pre><code>&lt;?
  include 'connect.php';
  
  //Get the details from previous page
  $SelectedCounty = $_POST["result"];
  
  // Select offers linked to selected county from form
  $result = mysqli_query($con,"SELECT * FROM offers WHERE tradingCounty ='" . $SelectedCounty . "'ORDER BY categoryIdName ASC;");
  
  // PREVIOUS ATTEMPTS - ALL WRONG - GGGGRRRRRRRRRRRR !!!!!!!!
  //------------------------------------------------------------
  //$result = mysqli_query($con,"SELECT * FROM offers WHERE tradingCounty LIKE" . $SelectedCounty);
  //$result = mysql_query("SELECT * FROM pdetails WHERE uid='" . $inputname . "';");
  //"SELECT * FROM `offers` WHERE `tradingCounty` LIKE
  //$result = mysqli_query($con,"SELECT * FROM offers;");
  //$result = mysql_query("SELECT * FROM pdetails WHERE uid='" . $inputname . "';");
  //$result = mysqli_query("SELECT * FROM offers WHERE tradingCounty=" . $SelectedCounty);
  
  
  //check to see if results is set - error if not.
  if(!$result)
  {
      die("&lt;p&gt;Error in listing tables: ". mysql_error()."&lt;/p&gt;");
  }
  
  //Show all records for selected county
  echo ("&lt;p&gt;&lt;h2&gt;Showing Latest Offers In : " . $SelectedCounty . "&lt;/h2&gt;&lt;/p&gt;");
  echo ("&lt;p&gt;&lt;a href='offers.php' target='_self'&gt;back to search menu&lt;/a&gt;&lt;/p&gt;");
  
  /*
  echo ("&lt;table border='1'&gt;");
  echo ("&lt;tr&gt;");
  echo ("&lt;td&gt;ID&lt;/td&gt;&lt;td&gt;Category&lt;/td&gt;&lt;td&gt;Business Name&lt;/td&gt;&lt;td&gt;Business Address&lt;/td&gt;&lt;td&gt;Address2&lt;/td&gt;&lt;td&gt;Address3&lt;/td&gt;&lt;td&gt;Town&lt;/td&gt;&lt;td&gt;County&lt;/td&gt;&lt;td&gt;Post Code&lt;/td&gt;&lt;td&gt;Telephone&lt;/td&gt;&lt;td&gt;URL&lt;/td&gt;&lt;td&gt;Email&lt;/td&gt;&lt;td&gt;Discount / Special Offer&lt;/td&gt;&lt;td&gt;valid from&lt;/td&gt;");
  */
  
  while($row = mysqli_fetch_row($result))
  {
      echo ("&lt;div style=' background-color: #EFF5FF; color: #06C; padding: 5px; float: left; border: 1px dotted #06C; margin: 10px; width: 300px; height: 300px; text-align: center; &gt;");
      // echo ("" . $row[0] . "");
      // echo ("&lt;/br&gt;");
      echo ("&lt;strong&gt;" . $row[1] . "&lt;/strong&gt;");  
      echo ("&lt;hr/&gt;");
      // echo ("&lt;/br&gt;");
      echo ("" . $row[2] . "");
      echo ("&lt;/br&gt;");
      echo ("" . $row[3] . "");
      echo ("&lt;/br&gt;");
      // echo ("" . $row[4] . "");
      // echo ("&lt;/br&gt;");
      // echo ("" . $row[5] . "");
      // echo ("&lt;/br&gt;");
      echo ("" . $row[6] . "");
      echo ("&lt;/br&gt;");
      echo ("" . $row[7] . "");
      echo ("&lt;/br&gt;");
      echo ("" . $row[8] . "");
      echo ("&lt;/br&gt;");
      echo ("" . $row[9] . "");
      echo ("&lt;/br&gt;");
      // echo ("" . $row[10] . "");
      // echo ("&lt;/br&gt;");
      echo ("" . $row[11] . "");
      echo ("&lt;/br&gt;");
      echo ("&lt;hr/&gt;");
      echo ("&lt;strong&gt;" . $row[12] . "&lt;/strong&gt;");
      echo ("&lt;/br&gt;");
      echo ("&lt;/div&gt;");
  
  /*  echo("&lt;tr&gt;");
      echo("&lt;td&gt;" . $row[0] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[1] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[2] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[3] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[4] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[5] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[6] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[7] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[8] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[9] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[10] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[11] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[12] . "&lt;/td&gt;" . "&lt;td&gt;" . $row[13] . "&lt;/td&gt;");
      echo("&lt;/tr&gt;");
  */  
  }
  // echo("&lt;/table&gt;");
  ?&gt;
  </code></pre>
  
  <p>what I'm getting can be seen <a href="https://i.stack.imgur.com/1LY4K.png" rel="nofollow noreferrer">here</a></p>