So I have a SQL select were it grabs the rankings of all users and then shows them in a table. But what I need to do now is grab which number the user is. So at the moment is echo's out highest to lowest but I need to find out what place that users is from the high to low.
$query = "SELECT
belongsto,
SUM(level) as sumLevel
FROM
user_pokemon
group by
belongsto
order by
sumLevel desc
LIMIT $pageLimit,".PAGE_PER_NO;
I am storing the users user-name in a $_SESSION['username'];
And there user-name for each monster is stored in the belongs too.
Would this work ?
$query = "select
(count(*) from user_pokemon where belongsto ='".$_SESSION['username']."' ) as position,
belongsto,
level
from user_pokemon
order by level;";
$res=mysql_query($query);