For option 1:
select count(1) as count from users where score>=$user_score
This should give you the person's rank. If you worried about multiple people having the same score as the current user change the >=
to a >
then you can add 1 to the result.
For option 2 and 3:
select * from users where score>$user_score order by score asc limit 2
select * from users where score<$user_score order by score desc limit 2
Or you could get all 5 (2 before, 2 after and current user) in one query once you have the rank from first query:
$start = $user_rank - 2;
$query = "select * from users order by score asc limit {$start},5";
Or if you didn't want current user or anyone with the same score as the current user to be included you could do this:
$start = $user_rank - 2;
$query = "select * from users where score!=$user_score order by score asc limit {$start},4";