L Posted January 3, 2008 Share Posted January 3, 2008 Hey, I want to figure out the total sum of all the values in the column, `amount`. I'm not sure how I would go about doing this. I have $donated = mysql_fetch_array(mysql_query("SELECT * FROM `donations` WHERE `month`='".date('m-Y')."'")); but when I echo out $donated['amount'] it just echos out the latest insert. thanks for your time ~L Quote Link to comment https://forums.phpfreaks.com/topic/84255-solved-adding-all-the-values-up-in-one-column/ Share on other sites More sharing options...
rajivgonsalves Posted January 3, 2008 Share Posted January 3, 2008 your code should be $donated = mysql_fetch_array(mysql_query("SELECT sum(`amount`) as amount FROM `donations` WHERE `month`='".date('m-Y')."'")); use the mysql sum function Quote Link to comment https://forums.phpfreaks.com/topic/84255-solved-adding-all-the-values-up-in-one-column/#findComment-429091 Share on other sites More sharing options...
L Posted January 3, 2008 Author Share Posted January 3, 2008 Sweet, thanx! That solved it. Quote Link to comment https://forums.phpfreaks.com/topic/84255-solved-adding-all-the-values-up-in-one-column/#findComment-429558 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.