title: PHP/MySQL Output Data in TD's
body: <p>How would I go about imposing a restriction on the number of HTML table columns when querying the database.</p>
  
  <p>For example, I have a MySQL table with the following values:</p>
  
  <pre><code>myTable:
    id     color
     1      red
     2      blue
     3      green
     4      pink
     5      purple
  </code></pre>
  
  <p>And when I run my query, instead of showing all rows in traditional table rows, e.g.</p>
  
  <pre><code>&lt;table&gt;
  &lt;?php
     while {
     echo "&lt;tr&gt;&lt;td&gt;$row['color']&lt;/td&gt;&lt;/tr&gt;;
           }
   ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Instead, I would like to impose something where, every three td's, a new tr is created.</p>
  
  <p>For example, it would output something like this:</p>
  
  <pre><code>&lt;table&gt;
    &lt;tr&gt;
    &lt;td&gt;red&lt;/td&gt;
    &lt;td&gt;blue&lt;/td&gt;
    &lt;td&gt;green&lt;/td&gt;
    &lt;/tr&gt;  &lt;-- Notice how after 3 columns, a new table row is created.
    &lt;tr&gt;
    &lt;td&gt;pink&lt;/td&gt;
    &lt;td&gt;purple&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p>Any way to achieve this?  </p>