Jump to content

summation values


web_master

Recommended Posts

Hi,

I got problem, how can I summary values in query?

 

In column `table_values` are different values (example; 10, 15, 24...)

$Query = mysql_query('SELECT * FROM `table` ORDER BY `table_id`');

if(!$Query) {echo mysql_error(); exit;}
while($REQUEST = mysql_fetch_array($Query)) {

$Values = $REQUEST['table_value'];


}

 

 

How can I summary values from rows?

(10 + 15 + 24 = 49)

 

Thnxs

Link to comment
https://forums.phpfreaks.com/topic/216348-summation-values/
Share on other sites

Your question doesn't make a great deal of sense with the example you have provided. Maybe....

 

$sql = "SELECT SUM(table_value) as tv_sum";
if ($result = mysql_query($sql)) {
  $row = mysql_fetch_assoc($result);
  echo $row['tv_sum'];
}

 

helps?

 

THNXS thorpe!!!

Link to comment
https://forums.phpfreaks.com/topic/216348-summation-values/#findComment-1124292
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.