Sum of results

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

 



Hi;

I've tried Googling this out but failed to search for an answer to this, so 
I'm posting to this list. I'd like to know if there's a way to get the sum 
this results:

// Results
Individual Daily Consumption
//AccountNo : Consumption
4146121002: 1.42
4146111002: 0.29
4146113002: 1.38
4146110002: 0.33
4146112002: 0.00
4146118002: 9.96
== MORE ==

// Code that generated the results
while ($row6 = mysql_fetch_assoc($queryconsumerresults)) {
	// Show Consumer AccountNo and their Consumption
	echo $row6['AccountNo'] . ": " . sprintf("%1.2f", (((($row6['Reading'] + 
$row6['KwHrAdjustment']) - ($row6['Reading1'] + $row6['KwHrAdjustment1'])) / 
$noofdays) * $row6['Multiplier'])) . "<br />";
}

I've tried getting the sum() from the MySQL table, but Multiplier is either at 
1 or 2 or 2.5 and the only way I can get an accurate total consumption is 
getting the sum from the results.

Is there a way I can place this code on an array? I've tried using
$indcons = array( sprintf("%1.2f", (((($row6['Reading'] + $row6
['KwHrAdjustment']) - ($row6['Reading1'] + $row6['KwHrAdjustment1'])) / 
$noofdays) * $row6['Multiplier']))) but I've obviously failed.

-- 
Dax Solomon Umaming
http://knightlust.com/
GPG: 0x715C3547

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux