Re: Calculating a total price

From: Date: Thu, 15 May 2003 16:26:41 +0000
Subject: Re: Calculating a total price
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-147727@lists.php.net to get a copy of this message
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

« previous php.general (#147727) next »