If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Calculating dynamic values for shopping cart quantity
i've got a self-built shopping cart that lists all items in the users cart along with a quantity textfield that the user can type in to update the quantity of each item. i am needing to be able to add together all those quantity textfield values for each item to get a total quantity of items in the cart. for instance...
a user is able to buy cd A and cd B. they can also specify that they want 1 copy of cd A and 12 copies of cd B. so i would need to add the two quantity textfields together to get a total quantity of 13(needed to calculate shipping).
how do i acheive this dynamically since the values are being pulled from a database and will change everytime per shopper?
two options: loop over the rows returned from the query that retrieved the cart items, an calculate the total quantity in the loop, or issue a separate query