keane89wolves Posted October 14, 2008 Share Posted October 14, 2008 Hello.. i have got on my website like a prediction league that all my members are involved in. I have also got a league table showing the top 15 people. I want it so if your not in the top 15 to be below the table showing what position your in.. so it would show the top 15.. then you.. maybe in 345th. How can i work out from the db query what position of the table that member is in though? I can get all the other details down, just not the actual league position Thanks for help keane Link to comment https://forums.phpfreaks.com/topic/128398-league-table/ Share on other sites More sharing options...
Maq Posted October 14, 2008 Share Posted October 14, 2008 code? Link to comment https://forums.phpfreaks.com/topic/128398-league-table/#findComment-665241 Share on other sites More sharing options...
keane89wolves Posted October 14, 2008 Author Share Posted October 14, 2008 $pos = 0 $pred = mysql_query("SELECT * FROM members WHERE id > '0' ORDER BY pred_points DESC LIMIT 20"); while($pred2 = mysql_fetch_array($pred)){ $name = $pred2['name']; $points = $pred2['pred_points']; $pos = $pos + 1; if($name==$username) { echo'<tr bgcolor="#CCCCCC"> <td>'.$userid.'</td> <td>'.$name.'</td> <td>'.$points.'</td> <td></td> </tr>'; } else { echo'<tr> <td>'.$pos.'</td> <td>'.$name.'</td> <td>'.$points.'</td> <td></td> </tr>'; } } echo '</table>'; Just the standard table, haven't got a clue with the other bit. Link to comment https://forums.phpfreaks.com/topic/128398-league-table/#findComment-665256 Share on other sites More sharing options...
Maq Posted October 14, 2008 Share Posted October 14, 2008 Are you asking if you're in 345th place you want to show 345 - 330? Link to comment https://forums.phpfreaks.com/topic/128398-league-table/#findComment-665261 Share on other sites More sharing options...
keane89wolves Posted October 14, 2008 Author Share Posted October 14, 2008 noo.. i want to pick a member out and know what place they are in. SORRY - Just realised this should be in PHP HELP. My apologises =) Link to comment https://forums.phpfreaks.com/topic/128398-league-table/#findComment-665264 Share on other sites More sharing options...
Barand Posted October 14, 2008 Share Posted October 14, 2008 To find the position of member with id = 123 SELECT COUNT(*)+1 as position FROM members WHERE pred_points > (SELECT pred_points FROM members WHERE id = 123) Link to comment https://forums.phpfreaks.com/topic/128398-league-table/#findComment-665403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.