title: Get user's position in a leaderboard?
body: <p>I'm making this game leaderboard and I am trying to get a specific user's position in this leaderboard. I have tried this but with no luck:</p>
  
  <pre><code>SELECT SUM(points) as points 
  FROM publicpoints 
  GROUP BY fk_player_id 
  WHERE points &gt; (SELECT SUM(points) as points 
                  FROM publicpoints 
                  WHERE fk_player_id = $playerid)
  </code></pre>
  
  <p>How should I go about this?</p>
  
  <p>---------------- EDIT -----------------</p>
  
  <p>I have also tried like this, but still no luck but maybe this claryfies what I try to accomplish:</p>
  
  <pre><code>$sql = mysql_query("SELECT SUM(points) mypoints FROM ".$prefix."_publicpoints WHERE fk_player_id=$playerid");
  $row = mysql_fetch_assoc($sql);
  
  $mypoints = $row['mypoints'];
  
  $sql = mysql_query("SELECT SUM(points) as points FROM ".$prefix."_publicpoints 
                          WHERE points &lt; $mypoints
                      GROUP BY fk_player_id");
  $row = mysql_fetch_assoc($sql);
  
  $rank = mysql_num_rows($sql);
  
  if(!empty($mypoints)){
      $rank = $row['rank']+1;
  } else {
      $rank = 0;
  }
  </code></pre>