Jump to content

[SOLVED] Aggregate Functions


mwl707

Recommended Posts

Hi Can anyone help please .

 

I am trying to write a function. The code is passed a variable which is used in a mysql query. (Code below) In the second to last line I always get 0 as a result when I know the result should be 3. If i use the following code I get the correct result

 

$screen_size = "i100s" ;

$result = mysql_query("SELECT SUM($screen_size) FROM event WHERE jobstatus = 'confirmed' ")  ;

 

while($row = mysql_fetch_array($result)){

$res = $row['SUM($screen_size)'] ;

 

echo "Total ". $row['jobstatus']. " = ". $res ;

echo "<br />";

 

In the second to last line I always get 0 as a result when I know the result should be 3. If i use the following code I get the correct result

 

$screen_size = "i100s" ;

$result = mysql_query("SELECT SUM($screen_size) FROM event WHERE jobstatus = 'confirmed' ")  ;

 

while($row = mysql_fetch_array($result)){

 

$res = $row['SUM(i100s)'] ;

 

echo "Total ". $row['jobstatus']. " = ". $res ;

echo "<br />";

 

Can anyone offer some advice ?

 

Thanks Mick

 

Link to comment
https://forums.phpfreaks.com/topic/157281-solved-aggregate-functions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.