I am trying to loop through MySQL results and return same dates & agents in a separate . The table containing this data has the number of tickets each agent works on a specific day. Each group of dates should be separated by a blank row in the table. Below is the code I am working with. I believe I have to do a foreach, but not sure how to get it working.
Here is a screenshot to a final table layout I am looking to achieve.

if($res && mysql_num_rows($res))
{
while($row = mysql_fetch_array($res))
{
if ($row['total_updated'] > 0) {
print "<tr>";
print "<td align=center>" . $row['date_added'] . "</td>";
print "<td nowrap>" . $row['agent'] . "</td>";
print "<td nowrap>" . $row['agent_location'] . "</td>";
print "<td align=center>" . number_format($row['total_updated']) . "</td>";
print "<td align=center>" . number_format($row['total_notes']) . "</td>";
print "<td align=center>" . number_format($row['total_closed']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app1_updated']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app1_notes']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app1_closed']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app2_updated']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app2_notes']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app2_closed']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app3_updated']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app3_notes']) . "</td>";
print "<td align=center>" . number_format($row['ticket_app3_closed']) . "</td>";
print "</tr>";
}
}
}
print "</table>";
<tr>and</tr>tags in there. We have no idea what your expected layout is, so that's the best you're going to get.mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.