title: php table: display 3 cells in each row
body: <p>I looked here:
  <a href="https://stackoverflow.com/questions/9099568/array-into-a-table-with-5-cells-in-each-row">Array into a table with 5 cells in each row</a></p>
  
  <p>but I cannot adapt my code..</p>
  
  <p>I need to display PHP array results in a table.
  The table needs to have 3 cells for each row.</p>
  
  <p>I don't know how to output the <code>&lt;tr&gt;</code> and <code>&lt;/tr&gt;</code> every 3rd row, and I don't know how to output the last <code>&lt;/tr&gt;</code> in case the table contains a number of records which is not a multiple of 3.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>echo "&lt;table&gt;";
  
  
  $num=mysql_numrows($result1);
  $i=0;
  while ($i &lt; $num)
  
  {
  
  
  $aaa=mysql_result   ($result1,$i,"aaa");
  $bbb=mysql_result   ($result1,$i,"bbb");
  
  echo "
  
  &lt;td&gt;$aaa $bbb&lt;/td&gt; ";
  
  $i++;
  
  }
  
  
  
  echo "&lt;/table&gt;";
  </code></pre>