I have the below code which produces the sample I have listed, but I would like to subtotal by Zone, Employee and give a grand total at the end. I thought I have seen this done before, but can't remember where.
Any help would be appreciated.
Thanks,
Mike
Sample:
Zone Employee Name Lines Pieces
LW Smith,Joe 80 163
UP Smith,Joe 80 163
UP Smith,Joe 80 163
UP Smith2,Joe 141 203
UP Smith2,Joe 86 458
Code:
if (($result = dosql($sql)) && (mysql_num_rows($result))) {
echo "<table width=100% bgcolor='" . $color . "' class='reportsborder' cellspacing=1 cellpadding=1>";
echo "<tr valign='top' align='left'>";
echo "<table width=100%><tr bgcolor='#ffffff'><td class='text9bold' width=2% align = 'left'> </td>";
echo "<td class='text9bold' width=5% align='center'>Zone</td>";
echo "<td class='text9bold' width=10% align='center'>Employee Name</td>";
echo "<td class='text9bold' width=5% align='center'>Lines</td>";
echo "<td class='text9bold' width=5% align='center'>Pieces</td>";
echo "</tr></table>";
while ($query_data = mysql_fetch_array($result)) {
If ($prev_emp_name <> $query_data["EmployeeFull"] and $rec_ct <> 0) {
echo "<table width=100% bgcolor='#ffffff' cellspacing=1 cellpadding=1>";
echo "<tr valign='top' align='left' bgcolor='#ffffff'><td> </td></tr></table>";
} else {
//no change
}
echo "<table width=100% bgcolor='" . $color . "' class='reportsborder' cellspacing=1 cellpadding=1>";
echo "<tr valign='top' align='left'>";
echo "<td class='text9' width=5% align='center'>".$query_data["Zone"]."</td>";
echo "<td class='text9' width=10% align='center'>".$query_data["LastName"].",".$query_data["FirstName"]."</td>";
echo "<td class='text9' width=5% align='center'>".$query_data["BatchLines"]."</td>";
echo "<td class='text9' width=5% align='center'>".$query_data["BatchPieces"]."</td>";
echo "</tr>";
echo "</table>";
if ($color == "#eeffee") $color = "#ffffff";
else $color = "#eeffee";
}
}
else {
echo "No Carts recorded in date range";
}