SC__Programmer Posted November 14, 2011 Share Posted November 14, 2011 I have a users table and every user has points.so i want to add the points from all the user sets. So like theres a id,username,password,email,and points in a set.i want to add all the points together to share on the site stats Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 14, 2011 Share Posted November 14, 2011 select sum(points) as points from my_table; Quote Link to comment Share on other sites More sharing options...
fenway Posted November 15, 2011 Share Posted November 15, 2011 I still prefer a WHERE clause and a GROUP BY, just so it won't be useless later on. Quote Link to comment Share on other sites More sharing options...
SC__Programmer Posted November 15, 2011 Author Share Posted November 15, 2011 when i tryed it,it came back with "Resource id #22"... i used this code, $points = mysql_query("select sum(points) as points from tb_users"); what am i doing wrong? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 15, 2011 Share Posted November 15, 2011 $points = mysql_query("select sum(points) as points from tb_users"); $row = mysql_fetch_array($points); echo $row[0]; Quote Link to comment Share on other sites More sharing options...
SC__Programmer Posted November 15, 2011 Author Share Posted November 15, 2011 Thanks 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.