Oi, pessoal, O usuário mikosiko do forum http://forums.devnetwork.net me passou o código que resolve perfeitamente o problema. Estou postando aqui para caso algum dia alguém precise. // Example
$heading_column = '<whatever is the name of your heading column>';
$last_heading = null;
while($row = your_fetch_assoc_statement){
// detect a change in the heading value and output the new heading
if($last_heading != $row[$heading_column]){
// detect if it is not the first heading - close out the previous section
if($last_heading != null){
// your code to close the previous section (table, div, etc)...
echo "close section<br />";
}
// output the new heading here...
echo "new section title - {$row[$heading_column]}<br />";
// save the new heading as the last_heading
$last_heading = $row[$heading_column];
}
// output the actual data here...
echo "data - {$row['your_data']}<br />";
}
// if there was any output - close out the last section
if($last_heading != null){
// your code to close the previous section (table, div, etc)...
echo "close section<br ?>";
}