Print Page | Close Window

totals

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2820
Printed Date: 29 March 2026 at 8:18am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: totals
Posted By: Mattblack
Subject: totals
Date Posted: 18 May 2003 at 3:28pm

help again please chaps and chappesses....

ive got a table in the MY BASKET section of my site which shows Item number, name, price per unit, quantity, and total for item (Which is price X quantity).

Now, at the end of my code i have a total value, which adds all the prices together.... thats my problem though.  It adds the prices per unit, not with the quantity too.  Am i being clear?  I only have a PRICE column in my database, not one which does the calculating for me.  I do that on the ASP page.  How do i get it to add all the values together of PRICE X QUANTITY from records which have been filtered in the SQL when the DB opened.

Hope you can help as this is really baffling me now.

Cheers folks,

Matt




Replies:
Posted By: ultramods
Date Posted: 18 May 2003 at 4:11pm

I dont know if i Completely follow you, but do you mean something like this?

WHILE NOT rs.EOF

    price = rs("price")

    quantity = rs("quantity")

    tempTotal = price * quantity

    total = total & tempTotal

rs.moveNext

WEND



Posted By: ljamal
Date Posted: 18 May 2003 at 7:21pm
If you have the price and the quantity stored in the database just return the price, quantity, and price * quantity with your SQL query,

select price, quanitity, price*quantity from ...


than you can add the total of price * quantity togther as listed above. I try to return the data as close as possible to form I need for display as it just take less time overall. Personal, I would just query the database for the total using,

select sum(price*quantity) from ...



-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: Mattblack
Date Posted: 19 May 2003 at 4:01pm

it worked!!!

Cheers guys, ur such a help




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net