Originally Posted by Fou-Lu
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.
What I am doing is, like I told earlier, I am marking attendance for every student as A or P through a checkbox. So if a checkbox is ticked the student is present and if not ticket the student is absent. And to mark the attendance, I have given a text field where the staff selects the date and this date gets stored in date column of database. Am i doing anything wrong?