title: Displaying mysql data in tables with group headers
body: <p>I have an SQL which returns records in a mysql table. Each record has many fields, and one of the field called "type" which is the type of sample. All samples are broadly classified into six types. I am displaying all the records in the table. But I want to group the data by 'type' and show separate tables with type as side heading.  At present I use this script.</p>
  
  <pre><code>echo "&lt;table class='wqtable'&gt;&lt;tr&gt;&lt;th&gt;USIN&lt;/th&gt;&lt;th&gt;Type&lt;/th&gt;&lt;th&gt;Date of Coll.&lt;/th&gt;   &lt;th&gt;Location&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;th&gt;H3&lt;/th&gt;&lt;th&gt;Cs&lt;/th&gt;&lt;th&gt;Sr&lt;/th&gt;&lt;th&gt;Analyst&lt;/th&gt;&lt;/tr&gt;";
  
  
  while($data=mysql_fetch_array($result)){
  
  echo "&lt;tr&gt;";
  
  echo "&lt;td&gt;".$data['usin']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['type']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['doc1']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['location']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['description']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['h3']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['cs']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['sr']."&lt;/td&gt;";
  echo "&lt;td&gt;".$data['name']."&lt;/td&gt;";
  
  echo"&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>This displays all the records in one table. I want to break the table when all the records with same value in type field is displayed and begin a new table for next type of samples. (like group header) Is there any easy way other than running separate SQLs?</p>