PHP - Display Players Actual Postion In Rankings Ladder e.g 1, 2, 5 etc

Associate
Joined
19 Mar 2005
Posts
569
I am making a squash ranking website and I would like to find out peoples position in the rankings i.e 1, 4, 10 etc. I currently have a table (playerRankings) which contains playerRankingsID, pRankingsScore, pPrevRankingScore. In pRankingsScore is the players points score and I have a query that sorts by this field name so the person with the most points is top of the league.

How would I go about implementing this, any help would be greatly appreciated.

Many Thanks

Leon
 
Last edited:
Change to reflect on your field names and tweakings etc.:

Code:
<?php

//connection stuff etc up here

$result = mysql_query("SELECT `name`, `points` FROM `players` ORDER BY `points` DESC") or die('Query error');

print "<table>\n<tr><th>Rank</th><th>Name</th><th>Score</th></tr>\n";

$rank = 1;
while ($row = mysql_fetch_assoc($result)) {

    print "<tr><td>{$rank}</td><td>{$row['name']}</td><td>{$row['points']}</td><tr>\n";

    $rank++;

}

print "</table>\n";

?>
:)
 
Back
Top Bottom