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.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Calculating dynamic values for shopping cart quantity

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-02-04, 14:48
asilaydying asilaydying is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
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?

make sense???????
- kelly
Reply With Quote
  #2 (permalink)  
Old 11-02-04, 15:23
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-02-04, 16:27
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
You could do it in a sigle query if you union the detail with the total.
Reply With Quote
  #4 (permalink)  
Old 11-03-04, 11:29
asilaydying asilaydying is offline
Registered User
 
Join Date: Nov 2004
Posts: 2
thanks

thanks for the help...i ended up getting the total by using Select SUM(quantity) statement.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On