<table border="1">
<tr>
<td>test_id</td>
<td>fruits</td>
<td>vegetables</td>
<td>meats</td>
<td>poultry</td>
<td>Totals</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['test_id']; ?></td>
<td><?php echo $row_Recordset1['fruits']; ?></td>
<td><?php echo $row_Recordset1['vegetables']; ?></td>
<td><?php echo $row_Recordset1['meats']; ?></td>
<td><?php echo $row_Recordset1['poultry']; ?></td>
<td><?php
$test1=$row_Recordset1['fruits'];;
$test2=$row_Recordset1['vegetables'];
$test3=$row_Recordset1['meats'];
$test4=$row_Recordset1['poultry'];
$testtotal=$test1+$test2+$test3+$test4;
if ($testtotal == '0') {
echo '0.00';
}else {
echo "$" . number_format($testtotal, 2, '.', ',');
}
?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<div> Need the sum of all in the "Totals" column to echo here (value should be $84.00) </div>
I have a table that has values in each column and php code to add up all values in each row to output the total dollar amount on each row. I having a very difficult time trying to echo out the sum of all rows only in the "TOTALS" column. The totals column of the table is not a field in the database table that stores the totaltest-table.tiff. Can anyone help with a solution to this problem?