Hi ho,
I'm finishing up a very simple shopping cart program and on the "view your cart" page I have a table that displays the columns; Item(s), Quantity, Price, Shipping and Total Price.
It's all standard stuff and I'm sure you've seen it all before.
So if a person buys 4 apples at $5 each, then there would be a row which reads;
Apples 4 5 2 22
...that's assuming there is a $2 shipping charge.
So, that's ok so far and all is well. But the trouble is... I'm wondering how to calculate and display a grand total at the very bottom of this table. This grand total value would add up all the "Total Price" values that have been collected when someone buys lots of apples, oranges, bananas and so on.
The main problem here is (I think) the fact that there is no "Total Price" column stored in any of my mysql database tables. That's because "total price", remember, is calculated from the cost of the individual item multiplied by the shipping cost for that item (both figures obtained from MySQL). So, although Item price and Shipping may be in MySQL, Total Price is not.
Can anyone point me in the right direction and tell me how to calculate and display a grand total?