View Single Post
Old 10-17-2012, 06:24 PM   PM User | #8
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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:
PHP Code:
    if (!isset($aRecords[$id]))
    { 
        
$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
        
); 
    else
    {
        
$aRecords[$id]['attendance'][$date] = $attendance;
    } 
To that, and modifying the foreach at the end to this:
PHP Code:
foreach ($aRecords AS $record)
{
    
$att array_pop($record);
    print(
'<tr>');
    
vprintf('<td>%s</td><td>%s</td><td>%s</td>'$record);
    
printf('<td>%s</td>'implode('</td><td>'$att);
    print(
'</tr>');

Looks like it would do it.
Fou-Lu is offline   Reply With Quote