hossfly007 Posted April 27, 2007 Share Posted April 27, 2007 I really dont know how to explain this but i will try my best. TABLE PEOPLE >id >date >name >points I am collecting data weekly on around 10 people. They get points every week. I am know how to make a DB query to sum the total of points that a person has made. But i'm not able to sort it with the highest points down to the lowest. Could someone help me? I have no idea where to start on coding this. Link to comment https://forums.phpfreaks.com/topic/48969-solved-sorting-a-db-query/ Share on other sites More sharing options...
The Little Guy Posted April 27, 2007 Share Posted April 27, 2007 if you do this: $row = mysql_fetch_array($sql); or $row = mysqli_fetch_array($sql); You may be able to do this: sort($row['points']); I'm not sure if that will work though Link to comment https://forums.phpfreaks.com/topic/48969-solved-sorting-a-db-query/#findComment-239928 Share on other sites More sharing options...
Psycho Posted April 27, 2007 Share Posted April 27, 2007 SELECT name, SUM(points) as total FROM people GROUP BY name ORDER BY total DESC Link to comment https://forums.phpfreaks.com/topic/48969-solved-sorting-a-db-query/#findComment-239929 Share on other sites More sharing options...
Delaran Posted April 27, 2007 Share Posted April 27, 2007 SELECT points,name from PEOPLE ORDER BY points DESC I think that would work, it should sort the points in numerical order. I'm still a noob at this, mind you Link to comment https://forums.phpfreaks.com/topic/48969-solved-sorting-a-db-query/#findComment-239932 Share on other sites More sharing options...
hossfly007 Posted April 27, 2007 Author Share Posted April 27, 2007 thanks everybody!! woohoo Link to comment https://forums.phpfreaks.com/topic/48969-solved-sorting-a-db-query/#findComment-239946 Share on other sites More sharing options...
Psycho Posted April 27, 2007 Share Posted April 27, 2007 Please mark the post as Solved. Link to comment https://forums.phpfreaks.com/topic/48969-solved-sorting-a-db-query/#findComment-239958 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.