papaface Posted October 30, 2009 Share Posted October 30, 2009 Hey I am trying to work out a way of selecting the top 50 high point scorers from my table. At the moment I have: $gettop = $ftcdb->get_col("SELECT * FROM `xperience_stats` ORDER BY `points_xperience` DESC LIMIT 0, 50"); foreach ($gettop as $userid) { if ($userid == $this->getUserId()) $allowskip = true; } It works absolutely fine. It selects the first 50 leaders and if their userid is one of the top 50 pulled from the table then $allowskip = true. But what happens if the 50th and 51st user have the same score? User 50 would be $allowskip = true but 51 wouldn't. Any idea how to get around that? With one query ideally. Any help would be appreciated Quote Link to comment Share on other sites More sharing options...
papaface Posted October 30, 2009 Author Share Posted October 30, 2009 No one can help me Quote Link to comment Share on other sites More sharing options...
cags Posted October 30, 2009 Share Posted October 30, 2009 Generally speaking you would just order by other important stats. For example in a football league (soccer for any Americans) you are ranked first on points, then on goal difference then it might be away goals (depends on the tournament). Sometimes for display purposes teams are ranked on arbitrary stats such as alphabetical order. If you don't want to do it this way then you could have the 'Top 50' being more than 50 individuals. You could simply use the query you already have, grab the `points_xperience` of the last player/person/team then do a further query to fetch all players that have the same amount of experience as them and add it to your result set (taking care not to add anybody twice obviously). 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.