Hello and welcome to PHP Builder!
Seems you found the answer... I would suggest that instead of having multiple arrays for each table header title, you should use a multidimensional array.
per your image, I would do something like:
$col = array(1 => 'Cust#',
2 => 'Customer Name',
3 => 'Invoice Amt.',
4 => 'Invoice#',
5 => 'Invoice Date'
);
$invoice = array(1 => array('cnum' => '0001',
'cust' => 'Bobs',
'iAmt' => '2.33',
'iNo' => '0100',
'date' => '20120526'
),
2 => array('cnum' => '0002',
'cust' => 'Jims',
'iAmt' => '32.33',
'iNo' => '0200',
'date' => '20120526'
),
3 => array('cnum' => '0003',
'cust' => 'Kelli\'s',
'iAmt' => '452.33',
'iNo' => '0300',
'date' => '20120526'
)
);
//colors for rows
$lite = '#FFFFFF';
$dark = '#C4F1FF';
//start your table
echo '<table cellpadding="5" cellspacing="0" border="1">';
//for counting
$c = 0;
while($c <= count($invoice)){
//set background color
$bg = ($c % 2) ? $lite : $dark;
echo '<tr>';
foreach($col as $k=>$v){
if($c == 0){
echo '<th>'.$v.'</th>';
}else{
foreach($invoice[$c] as $a => $b){
echo '<td bgcolor="'.$bg.'">'.$b.'</td>';
}
//break out and pull next data set
break;
//close foreach loop
}
}
//add up invoice amounts
$total += $invoice[$c]['iAmt'];
//echo out totals
if($c == count($invoice)){
echo '<tr><td colspan="2">3 Invoice *** GRAND TOTAL ***</td>';
echo '<td><strong>$'.number_format($total,2).'</td><td colspan=2> </td></tr>';
}else{
echo '</tr>';
}
$c++;
//close while loop
}
echo '</table>';