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 Quote 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? Quote 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/216348-summation-values/#findComment-1124292 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.