jasonc Posted June 2, 2008 Share Posted June 2, 2008 I am having problems adding all numbers in a column, not a count rows but count the actual numbers in the whole column. this is what i have so far... thanks in advance for your help $count = mysql_query("SELECT count(numbers) from `info`"); Quote Link to comment Share on other sites More sharing options...
peranha Posted June 2, 2008 Share Posted June 2, 2008 $count = mysql_query("SELECT count(numbers) from `info`"); you want to use SUM $count = mysql_query("SELECT SUM(numbers) from `info`"); Quote Link to comment Share on other sites More sharing options...
jasonc Posted June 2, 2008 Author Share Posted June 2, 2008 i changed to what you had but it did not work it shows an error about a resource id #6 i thought maybe i had not got the field set correctly but i think it is, it is set to int(11) Quote Link to comment Share on other sites More sharing options...
jasonc Posted June 2, 2008 Author Share Posted June 2, 2008 the field is set to int(11) and not NULL and all have zeros in them. `numbers` int(11) NOT NULL default '0', Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 2, 2008 Share Posted June 2, 2008 To get help, you would need to post your code and post the actual error message. Quote Link to comment Share on other sites More sharing options...
jasonc Posted June 2, 2008 Author Share Posted June 2, 2008 $count = mysql_query("SELECT count(numbers) from `info`"); you want to use SUM $count = mysql_query("SELECT SUM(numbers) from `info`"); i changed to what you had but it did not work it shows an error about a resource id #6 i thought maybe i had not got the field set correctly but i think it is, it is set to int(11) maybe it is this part which is wrong.... echo($count); Quote Link to comment Share on other sites More sharing options...
fenway Posted June 2, 2008 Share Posted June 2, 2008 maybe it is this part which is wrong.... echo($count); That's right... you need to use mysql_result($count,0,0) to get the count itself. Quote Link to comment 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.