Name | score | rank |
Sam | 81 | 1 |
Tracy | 78 | 2 |
Jessice | 78 | 2 |
Albert | 75 | 4 |
$query="SELECT *FROM ScoreTable ORDER BY score DESC";
$result=mysql_query($query);
$i=1;
while ($row=mysql_fetch_array($result)) {
if ($row[score]==$LastScore) {
$row[rank]=$LastRank;
}
else {
$row[rank]=$LastRank=$i;
$LastScore=$row[score];
}
echo "<tr><td>$row[Name]</td><td>$row[score]</td><td>$row[rank]</td></tr>";
$i++;
}
沒有留言:
張貼留言