Re: Calculating a total price
| From: | Scott St. John | Date: | Thu, 15 May 2003 16:33:45 +0000 |
| Subject: | Re: Calculating a total price | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147730@lists.php.net to get a copy of this message | ||
I am working on it now, I have to inner join two tables so my sql code is
getting a little hairy.
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