I'm looking for some assistance with a php script I'm writing. It creates a table that is then exported to an excel file for download, the issues as I see them are as follows:
$students
contains 559 items and the $classes
has 22 items and $attributes
has 6 items
<tbody>
<?php foreach($students as $student){
$pupil = Students::retrieveByPK($student['adno']); ?>
<tr>
<td><?php echo strtoupper($pupil->surname); ?></td>
<td><?php echo $pupil->first_name; ?></td>
<td><?php echo $pupil->year_group; ?></td>
<?php foreach($classes as $class){
$shortYear = str_replace('Year ', '',$pupil->year_group);
$slashPos = strpos($class['class_name'],'/');
$className = $shortYear.substr($class['class_name'],1);
$classId = Classes::idFromClassName($className);
foreach($attributes as $attribute){
$attr = AttributeResults::getExportAttribute($pupil->adno, $classId, $attribute['attribute_id']); ?>
<td align="center"><?php echo $attr[0]['attribute_value']; ?></td>
<?php } ?>
<?php } ?>
</tr>
<?php } ?>
</tbody>
I'm essentially running the AttributeResults::getExportAttribute
method in the region of 74000 times and wondered if there was a better way of bringing this data back?
Any assistance would be greatly appreciated.