MYSQL / PHP Scoreboard - Return position

Hi,

Basically I’ve got a MYSQL database that has tables that relate to levels on my game for the following to be stored in:

id, usernames, scores and times.

I’ve worked out how to add new entries into the database and load a set sample after ordering the table (e.g. the highest 10 scores) but is it possible to:

add the score, sort by score then return the position of that score and the next 10 scores below it?

I searched on google and managed to find an example that someone had solved, but didn’t understand it really and when I tried to implement it, it wouldn’t work.

SET @rownum := 0;

$result = SELECT * FROM(SELECT @rownum := @rownum+1 AS rank, id, name, score, time, ms FROM $table ORDER BY score DESC) AS derived_table WHERE rank = 3;

I’ve only done a very minimal amount of both PHP and MySQL so it is likely that I have overlooked something here, but I couldn’t really find any other examples and spent a while trying to get that code to work.

Any input is appreciated,
Mental.