PHP Code:
<?php $week = '<table cellpadding="0" cellspacing="0" class="week">';
$headings = array(date("D, d/m"));
for($d=1; $d<7; $d++){
$day = mktime(0, 0, 0, date("m"), date("d")+$d);
array_push($headings, date("D, d/m", $day));
}
$times = array('09:30-10:30','10:30-11:30','11:30-12:30','12:30-13:30','13:30-14:30','14:30-15:30','15:30-16:30','16:30-17:30','17:30-18:30','18:30-19:30','19:30-20:30','20:30-21:30');
$week.= '<tr class="week-row-time"><td class="week-time-np">Deliver between the following times:</td><td class="week-day-head">'.implode('</td><td class="week-day-head">',$headings).'</td></tr>';
for($i=0, $n=sizeof($times); $i<$n; $i++){
$week.='<tr class="week-row-time"><td class="row-time">'.$times[$i].'</td>';
for($j=0, $m=sizeof($headings); $j<$m; $j++){
foreach($quotes as $q1) {
foreach($q1['methods'] as $q2) {
if(substr($q2['title'],0,5)==substr($headings[$j],5,5) && (mktime(0,0,0,substr($q2['title'],6,2),substr($q2['title'],9,2))<=mktime(0,0,0,substr($times[$i],6,2),substr($times[$i],9,2)) && mktime(0,0,0,substr($q2['title'],6,2),substr($q2['title'],9,2))>mktime(0,0,0,substr($times[$i],0,2),substr($times[$i],3,2)))) {
$week.='<td class="week-time"><center>'.zen_draw_radio_field('shipping', $q1['id'] . '_' . $q2[$j]['id'], $checked, 'id="ship-'.$q1['id'] . '-' . str_replace(' ', '-', $q2[$j]['id']) .'"').'<label for="ship-'.$quotes[$i]['id'].'-'.str_replace(' ', '-', $q2[$j]['id']).'" class="checkboxLabel" >'.substr($q2['title'],12,30).'</label></center></td>';
}
else {
$week.='<td class="week-time"><center>N/A</center></td>';
}
}
}
}
$week.='</tr>';
}
$week.='</table>';
echo $week;
?>
I'm having trouble with the looping, as it is making too many columns and I can't see what is wrong with the code. Any suggestions would be welcome.