web_master Posted October 20, 2010 Share Posted October 20, 2010 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 More sharing options...
trq Posted October 20, 2010 Share Posted October 20, 2010 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? Link to comment https://forums.phpfreaks.com/topic/216348-summation-values/#findComment-1124290 Share on other sites More sharing options...
web_master Posted October 20, 2010 Author Share Posted October 20, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.