PHP:从MYSQL订单获取排名[重复]

This question already has an answer here:

I am wondering how to get the rank of a player who was wrote to my page using:

    $res = $con->query("SELECT * FROM hiscores ORDER BY `0` DESC LIMIT 50");

I have a list of my players on my page organized by their values in column 0. How do I get what rank the player is based on the ORDER BY?

</div>

You should ORDER BY score DESC

Then something like:

foreach ($res as $player) {
    echo "Rank #"
       . (intval(key($player)) + 1)
       . " for player "
       . $player['playerName']
       . "<br>" . PHP_EOL;
}

The logic is to take the element's index and increment it by one

$player[0] = 1
$player[1] = 2
...