Php - ranking - I need your help

Hello there, I’m stuck and I don’t know how to do :(. I hope you can help me :slight_smile:
Can you help me, please, with rank system?.
I have code for ranklist page, showing users by position, its fine, it is what I need, but I need one more: I need rank for each user in his profile. Explain: User number 150 is position 20 on ranklist page, how to show him, he is position 20 in his profile page? I tried some codes, but everytime show him position 1 and in ranklist is different position.
I will be very grateful for any help.
Man thanks!
Here is my code for rank:

$sql="SELECT * FROM users ORDER by POSTS desc";
      $ranklist=mysqli_query($connection,$sql);
      $i= 0;
                while($result=mysqli_fetch_array($ranklist)) {
					$i = $i + 1;?>

        <tr> 
          
            <td><?php echo "Position " . $i ?> </td>
		 <td><?php echo $result['name'] ?></td>
        <td><?php echo "Posts ".$result['posts']?></td>
        
        </tr> 
Sponsor our Newsletter | Privacy Policy | Terms of Service