Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SUM question in ASP

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
Greetings,

I am trying to modify a shopping cart to reflect total weight. Here's the SQL statement I am working with:

set rscart=db.execute("select name,productid,price,saleprice,weight from products where productid=" & acart(i,0))

What I need is a sum of the weight for that particular cart. How do I do that? Any ideas would be appreciated. Thanks in advance...
 
Try

<%
Dim totweight

totweight = 0

set rscart=db.execute(&quot;select name,productid,price,saleprice,weight from products where productid=&quot; & acart(i,0))

Do Until rscart.EOF

totweight = totweight + rscart(&quot;weight&quot;)

rscart.movenext
loop
%>
 
It's only returning the first weight instead of summing them up... I can't figure out why.

Here's what I've used for the shipping to sum up quantity. Could I use something like this for the weight?
I've tried to modify it, but I just don't know enough to do it.
shiptotal = 0
qty = session(&quot;cart&quot;)
for i = 0 to ubound(qty)
shiptotal = shiptotal + qty(i,1)
next
'response.write shiptotal
session(&quot;shipping&quot;)=shiptotal

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top