Re: Adding Up MySQL Results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux