I am definitely stumped on how to arrange a result set.
I have a table which currently contains strictly dates.
DATES
ID Dates
1 2015-05-26
2 2015-05-27
3 2015-05-28
4 2015-05-29
5 2015-05-30
each of those dates are also the name of the table for that day which keeps track which user/agent was present for training.
2015-05-26
ID Attendance
101 Present
201 N/A
301 Present
401 Present
501 Present
The end goal for this is to create the following table:

Now here is what I have accomplished for the table header.
$data_date = true;
$list = "SELECT * FROM list ORDER BY id DESC LIMIT 5";
$result = mysql_query($list);
while ($row = mysql_fetch_assoc($latest)){
$dates[] = $row['date'];
}
foreach($dates as $x){
$data_date .= "<th>$x</th>";
}
By simply echoing out the $data_date I am able to display the headers like the following.
<table>
<tr>
<th>AGT</th>
<?php echo $data_date; ?>
</tr>
<tr>
</tr>
</table>

So far so good. The final step of taking the array and creating new row for each and querying each day from the dates array has me at a loss.
I've been trying for over an hour and cant seem to wrap my head around the array needed to query a new row for each agent.
Any pointers or help would definitely be appreciated.