Re: Calculating a total price

From: Date: Thu, 15 May 2003 17:08:18 +0000
Subject: Re: Calculating a total price
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-147737@lists.php.net to get a copy of this message
This works and here is the sql code: select orders.fk_prod_size_id, orders.order_qty, prod_size.prod_price, SUM(prod_size.prod_price * orders.order_qty) from (orders orders INNER JOIN prod_size prod_size ON orders.fk_prod_size_id = prod_size.prod_size_id) But I need a way to tabulate the total order, here is the result of the above code:
54              1           52.00      52.00 
54              50          52.00      2600.00 
65              1           14.25      28.50
I need a quick way to tabulate the total of the 3 columns on the right - I can't think, maybe I should go to lunch :) -Scott At 12:26 PM 5/15/2003 -0400, Adam Voigt wrote:
Actually I think I was using too many steps, I think you don't need the sub-select at all, try: SELECT SUM(qty*price) FROM tablename WHERE userid = '1'; On Thu, 2003-05-15 at 12:17, Adam Voigt wrote: SELECT SUM(SELECT (qty * price) FROM tablename WHERE userid = '1'); Assuming you have a DB with sub-select support, something like that? On Thu, 2003-05-15 at 12:09, Scott St. John wrote:
I need some clear eyes :) I have a site in which a customer can select an item and then purchase it. It is not a shopping cart - just a way for marketing departments to place orders for shirts, pens, golf balls, etc. I have a table that holds the price of each item and also a table that holds the quantity they want. Calculating the individual sale items I do this: $order_total = ($prod_qty * $prod_price); But I need to come up with a total price at the end of the transaction, would a foreach array be my best bet? Thanks in advance...... -Scott
-- Adam Voigt (adam@cryptocomm.com) Linux/Unix Network Administrator The Cryptocomm Group -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
------------------------------------------------------------------------------ Scott St. John, Technical Evangelist Talon Network Services, Inc. WorkURL: www.talon.net HomeURL: www.scottah.com AIM: scottstjohn102

« previous php.general (#147737) next »