I'm trying to write a leaderboard where I can show the player's position and all the scores around him (maybe 10 above him and 10 below). Maybe this user's score is at #95,000 so my first question is: how do I know his position, and how can i grab the scores above and below him based on that information?
$sql = "SELECT id, firstname, lastname, facebookid, score FROM users ORDER BY score";
$result = $conn->query($sql);
That sorts the scores, but what if I want to find where the facebook id "0002941" is ranked?
I'm using this script to go through and view all of them, but it takes too long to scan to find this user. I'm hoping it's possible to jump to them instantly:
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"] . " " . $row["score"] . " end";
echo '<br>';
}
}