owner Posted November 25, 2007 Share Posted November 25, 2007 How would you add up all the values in a column in the mySQL database. here is what I have. So the value returned would be 115. For the name of the column, it can be blah and the table is called red. Thanks, -Owner Link to comment https://forums.phpfreaks.com/topic/78809-solved-add-up-all-the-values-in-a-column/ Share on other sites More sharing options...
pocobueno1388 Posted November 25, 2007 Share Posted November 25, 2007 <?php $query = mysql_query("SELECT SUM(blah) as sum FROM table_name"); $row = mysql_fetch_assoc($query)or die(mysql_error()); echo $row['sum']; //will print out sum ?> Link to comment https://forums.phpfreaks.com/topic/78809-solved-add-up-all-the-values-in-a-column/#findComment-398833 Share on other sites More sharing options...
owner Posted November 26, 2007 Author Share Posted November 26, 2007 thanks much! Link to comment https://forums.phpfreaks.com/topic/78809-solved-add-up-all-the-values-in-a-column/#findComment-399070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.