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.
echo "<table class='wqtable'><tr><th>USIN</th><th>Type</th><th>Date of Coll.</th> <th>Location</th><th>Description</th><th>H3</th><th>Cs</th><th>Sr</th><th>Analyst</th></tr>";
while($data=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>".$data['usin']."</td>";
echo "<td>".$data['type']."</td>";
echo "<td>".$data['doc1']."</td>";
echo "<td>".$data['location']."</td>";
echo "<td>".$data['description']."</td>";
echo "<td>".$data['h3']."</td>";
echo "<td>".$data['cs']."</td>";
echo "<td>".$data['sr']."</td>";
echo "<td>".$data['name']."</td>";
echo"</tr>";
}
echo "</table>";
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?