Hi,
I am playing with a shopping cart and am trying to get a grand total to be added up. I have done some research on summing a column and it does make sense, but can't see how to get it to work in the script that I have.
below is the script, any advice would be greatly appreciated.
<table border="0" cellpadding="2" cellspacing="1" width="100%" class="gray3">
<tr>
<td> </td>
<td class="rowHeaderfont">Sku#</td>
<td class="rowHeaderfont">Name</td>
<td class="rowHeaderfont">Price</td>
<td class="rowHeaderfont">Options</td>
<td class="rowHeaderfont">Amt</td>
<td class="rowHeaderfont">Total</td>
</tr>
<?php
$query = "SELECT *
FROM $table_pro
WHERE ";
for($i=0; $i<$total_items; $i++)
if ($i == ($total_items-1)) {
$query .= "ProductID = '$items_tray[$i]' ";
} else {
$query .= "ProductID = '$items_tray[$i]' or ";
}
if (!($result1 = mysql_db_query($db_name,$query))) {
DisplayErrMsg(sprintf("internal error %d:%s\n",
mysql_errno(), mysql_error()));
exit();
}
$j = 0;
while($row = mysql_fetch_array($result1)) {
?>
<tr class="bgWhite">
<td class="rowfont"><?php echo $j+1; ?></td>
<td class="rowfont""><?php echo $row['ProductID']; ?></td>
<td class="rowfont"><?php echo $row['ProductName']; ?></td>
<td class="rowfont" align="right">$<?php echo $row['ProductPrice']; ?></td>
<td class="rowfont"><?php echo $row['ProductOption']; ?></td>
<td class="rowfont"><input class="input" type="Text" size="3" name="<?php echo "qty".$j; ?>" value="<?php echo $quantity[$j]; ?>"></td>
<td class="rowfont" align="right">$<?php $total = $row['ProductPrice'] * $quantity[$j]; ?>
<?php echo (number_format($total,2)); ?></td>
</tr>
<?php
$j++;
}
?>
<tr class="bgWhite">
<td colspan="5"><input class="button" type="submit" name="button" value="Update"> | <input class="button" type="submit" name="button" value="Check Out !!"></td>
<td colspan="2"><?php echo $Grand_Total; ?></td>
</tr>
</table>