Re: Adding Up MySQL Results

From: Date: Mon, 17 Jan 2005 15:27:06 +0000
Subject: Re: Adding Up MySQL Results
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-38178@lists.php.net to get a copy of this message
I guess this is what you mean: sum(quantity)*price price
        450.00		15.00
        479.99 		29.99
... ... is that right? JeRRy wrote:
<snip> I run this mysql query: "select sum(quantity)*price,price from sale where dvd_id=1 group by price"; I get this result: sum(quantity)*price price
     	450.00		15.00
      	29.99 		29.99
I want to display the sum of the values in the first column (450.00+29.99), but I cannot figure out how to do this! Can someone clue me in? </snip> <?php // Multiplying with varaibles $factorA = number_format(system_value('sum'); $factorB = number_format(system_value('price'), 0); $product = $factorA + $factorB; echo $product; ?> Something like that? You'll have to obviously play with this to make it work for you. But calculations work like your Windows Calculator number keypad. + = plus - = minus * = multiply etc... Look at these: http://au.php.net/manual/en/function.number-format.php http://au.php.net/round J Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com


« previous php.db (#38178) next »