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 Link to comment https://forums.phpfreaks.com/topic/251150-adding-values-from-different-sets/ 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; Link to comment https://forums.phpfreaks.com/topic/251150-adding-values-from-different-sets/#findComment-1288169 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. Link to comment https://forums.phpfreaks.com/topic/251150-adding-values-from-different-sets/#findComment-1288193 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? Link to comment https://forums.phpfreaks.com/topic/251150-adding-values-from-different-sets/#findComment-1288203 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]; Link to comment https://forums.phpfreaks.com/topic/251150-adding-values-from-different-sets/#findComment-1288205 Share on other sites More sharing options...
SC__Programmer Posted November 15, 2011 Author Share Posted November 15, 2011 Thanks Link to comment https://forums.phpfreaks.com/topic/251150-adding-values-from-different-sets/#findComment-1288207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.