PDA

View Full Version : How to total return my Shopping Cart total cost.


tux
10-09-2009, 06:01 PM
Hi All,

Struggling a bit here with getting the total cost of items in my shopping cart.

I have built a shopping cart which is working okay but I am struggling to sort out the total cost of the cart.

I am querying the DB to get the contents of the cart, so for example the cart may have......

Item1 -- qty = 1, price = 10
Item2 -- qty = 2, price = 20
Item3 -- qty = 3, price = 30

.... so I need to find the cost of each row and I guess build an array from the DB query, then total them.

So how do I loop through the rows, calculate them and add them together to get the total cost.

Hope this makes sense.

Regards, Paul.