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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

total within an array 1

Status
Not open for further replies.

benniesanders

Programmer
Jan 20, 2002
199
US
I've never been good at this. I have some shopping cart software and I need to total the quantity of certain product numbers. Here's the array:
Code:
acart=session("cart")
for i=lbound(acart) to ubound(acart)
[COLOR=#ff0000]acart(i,0) being the product ID and acart(i,1) being the quantity[/color]
if acart(i,0)<>"" and acart(i,1)<>"" then
set rscart=db.execute("select name,productid,price,saleprice,noship from products where productid=" & acart(i,0))
if acart(i,0)=504 or acart(i,0)=505 or acart(i,0)=506 then
'this is where I'm stuck
end if

...

What I need to find out is the count of the products (acart(i,1)) that match product id 504, 505 or 506 and I'm just not smart enough to do that. Any help would be appreciated. Many thanks in advance.
 
What I need to find out is the count of the products (acart(i,1)) that match product id 504, 505 or 506 ...

[tt]
acart = session("cart")
ProdCount = 0

for i = lbound(acart, 1) to ubound(acart, 1)
if acart(i,0) = 504 _
or acart(i,0) = 505 _
or acart(i,0) = 506 then
ProdCount = ProdCount + acart(i,1)
end if
next
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top