Suppose I have a table named "farmstuff" like this highly simplified and strange looking one;
id mark pjob role jobDesc 1 1 horses Smithy Smith Stuff 1 1 horses Smithy More Smith stuff 1 1 horses Smithy Even More Smith stuff 2 1 cows Farrier Put left front shoe on 2 1 cows Farrier Put right front shoe on
And my PHP to read it is like this:
<?php
$tableheader = "<table><thead><tr><th>col3</th><th>col4</th></tr></thead><tbody>";
$sql = "SELECT id, mark, pjob, role, jobDesc FROM farmstuff WHERE mark = 1 ORDER BY id";
$echo($tableheader);
foreach($found->query($sql) as $row) {
echo ("<tr>");
}
echo("<td>$row[role]</td>");
echo("<td>$row[jobDesc]</td>");
} echo("</tr></tbody></table>");
?>
And what I want is two tables like below. Despite the values of the other variables, I want to break the tables at the change in value of id. So if its 1 then the first title is horses, if its 2 then the title is cows. Keep in mind these are tables now. So first how do I create two tables from the output of the SQL with the appropriate break, and second how should I put the label on top of each as in the example below?
horses col4 col5 Smithy Smith Stuff Smithty More Smith Stuff Smithy Even More Smith Stuff cows col4 col5 Farrier Put left front shoe on Farrier Put right front shoe on