Problem with Ranking code

I need help fine tuning my code. This code shows ranking like:

Rank - Points
1 - 120
2 - 100
2 - 100
3 - 99

But I need it to show it like:

1 - 120
2 - 100
2 - 100
4 - 99

**Notice the 4th result is ranked 4th instead of 3rd…since the two tied for 2nd are actually 2nd and 3rd.


                <?php
    
    echo '<table cellpadding="3" cellspacing="0" style="width:100%;">
                    <tr>
                        <td>Rank</td><td>User</td><td>Points</td>
                    </tr>';
    $rank = 0;
                    
    while($row = mysql_fetch_array($Points)){ 
    
    $score = $row['Points'];
    
           $r = ($score == $oldScore)? $rank : ++$rank;
         echo '
         
         <tr>
         <td class="topline">' . $r . '</td>
         <td class="topline">' . $row['Name'] . '</td>
         <td class="topline">' . $score . '</td>
         </tr>';
    
    $oldScore = $score;
    }
    echo '</table>';
    
    ?>