maroqand Posted June 29, 2009 Share Posted June 29, 2009 Let's say I wanna count all entered data which is in one specific column. I tried this code from another forums, but it gives me only total rows number: $result = mysql_query("SELECT * FROM $table"); while($row = mysql_fetch_array($result)) { $Total = Total + $row['Points']; } echo $Total; I wanted something like this: ----------------------------' USERS | POINTS | ---------------------------- John | 72 | ---------------------------- Smith | 68 | ---------------------------- James | 52 | ---------------------------- Linda | 87 | ===============' Total points: | 279 | --------------------------- Thanks so much, I appreciate! Quote Link to comment https://forums.phpfreaks.com/topic/164162-need-help-count-all-data-from-one-sql-column/ Share on other sites More sharing options...
Hybride Posted June 30, 2009 Share Posted June 30, 2009 SUM(). Quote Link to comment https://forums.phpfreaks.com/topic/164162-need-help-count-all-data-from-one-sql-column/#findComment-866057 Share on other sites More sharing options...
fenway Posted June 30, 2009 Share Posted June 30, 2009 SELECT sum(points) from $table Quote Link to comment https://forums.phpfreaks.com/topic/164162-need-help-count-all-data-from-one-sql-column/#findComment-866663 Share on other sites More sharing options...
Ken2k7 Posted July 1, 2009 Share Posted July 1, 2009 You can use your SELECT statement you have up there and then UNION it with the SQL fenway posted. Quote Link to comment https://forums.phpfreaks.com/topic/164162-need-help-count-all-data-from-one-sql-column/#findComment-866953 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.