I don't understand why you need this field at all. The impression I have of the table is if a record exists, that it is assumed that attendance would exist.
Does a record exist for every date and applied either an A or P in the attendance field for every student? It's a bit of a waste in dataspace IMO to do that, but you can modify it easily as well by changing the array creation in the while:
$aRecords[$id] = array(
'id' => $id,
'studname' => $studname,
'studroll' => $studroll,
'attendance' => array($date => $attendance), // I don't know what this is, so I'm leaving it out
$aRecords[$id]['attendance'][$date] = $attendance;
To that, and modifying the foreach at the end to this:
foreach ($aRecords AS $record)
$att = array_pop($record);
printf('<td>%s</td>', implode('</td><td>', $att);
Looks like it would do it.