Hi, im having trouble looping through an array to achieve the desired layout i want to achieve. I can successfully retrieve the data and output it into 1 long table, however i am wanting to output it as 2 tables see code below
The php code i have almost works i know where its going wrong but cant for the life of me thingk how to srt it. to save on post size ive removed the cosmetic side of code.
any advice is appreciated.
<?php for ($i=1; $i<=2; $i++){
$bttot1 = $bttot1 + $rotadetail['pa_hrs0800'];
$lttot1 = $lttot1 + $rotadetail['pa_hrs1300'];
$tttot1 = $tttot1 + $rotadetail['pa_hrs1700'];
$nttot1 = $nttot1 + $rotadetail['pa_hrs2200'];
$ettot1 = $ettot1 + $rotadetail['pa_rotaETimeDur'];
?>
<table align="center" border=0 cellspacing=0 cellpadding=0 width=633>
<tr>
<td colspan=7 valign=top style="height:4px; "></td>
</tr>
<tr align="center">
<td width="70" rowspan="2">Week <?php echo $i; ?></td>
<td width="80" colspan=1 bgcolor="#DBE5F1">Breakfast</td>
<td width="80" colspan=1 bgcolor="#DBE5F1">Lunch</td>
<td width="80" colspan=1 bgcolor="#DBE5F1">Dinner</td>
<td width="80" colspan=1 bgcolor="#DBE5F1">Bed</td>
<td width="120" colspan=2 bgcolor="#DBE5F1">Extra Time</td>
</tr>
<tr align="center" bgcolor="#DBE5F1">
<td width="80" colspan=1>08:00-09:00</td>
<td width="80" colspan=1>13:30-14:30</td>
<td width="80" colspan=1>17:00-18:00</td>
<td width="80" colspan=1>22:00-23:00</td>
<td width="120" colspan=1>Start</td>
<td width="60">Duration</td>
</tr>
<?php foreach($rotadetails as $rotadetail): ?>
<tr>
<td colspan=1><?php echo date("l",$rotadetail['pa_rotaDate']); ?></td>
<td colspan=1><?php echo $rotadetail['pa_hrs0800']; ?></td>
<td colspan=1><?php echo $rotadetail['pa_hrs1300']; ?></td>
<td colspan=1><?php echo $rotadetail['pa_hrs1700']; ?></td>
<td colspan=1 bgcolor="#DBE5F1"><?php echo $rotadetail['pa_hrs2200']; ?></td>
<td ><?php echo $rotadetail['pa_rotaETime']; ?></td>
<td><?php echo $rotadetail['pa_rotaETimeDur']; ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan=7 valign=top style="height:4px; "></td>
</tr>
<tr>
<td colspan=1 align="right" valign=top>TOTAL </td>
<td colspan=1><?php echo $bttot1; ?></td>
<td colspan=1><?php echo $lttot1; ?></td>
<td colspan=1><?php echo $tttot1; ?></td>
<td colspan=1 bgcolor="#DBE5F1"><?php echo $nttot1; ?></td>
<td colspan=2><?php echo $ettot1; ?></td>
</tr>
</table>
<?php } ?>
how i want to look
how it looks