title: why does foreach skip 2 rows from the query result?
body: <p>For 10 rows in the query it only returns 8 rows but i get the fields right:</p>
  
  <p>For Query data which returns less than 2 rows I get an error.</p>
  
  <pre><code>//create table to display all data
  echo "&lt;table border="1"&gt; ";
  echo "&lt;tr&gt;";
  $row = mysqli_fetch_assoc($result);
      foreach($row as $key =&gt; $value) 
          {
              echo "&lt;th&gt;$key&lt;/th&gt;";
          }
  echo "&lt;/tr&gt;";
  
  while (($row = $result-&gt;fetch_assoc()) !== null) 
  {
    $output = array();
    $i=1;
  
    echo "&lt;tr&gt;";
  
      foreach ($row as $columnName =&gt; $columnValue) 
          {
              $output[] = $columnName."=&gt;". $columnValue;
              echo "&lt;td&gt;".$columnValue."&lt;/td&gt;";
          }
  
    echo "&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  </code></pre>