Du kan använda MySQL:s between
och limit
klausul för detta:
$range = 5; // you'll be selecting around this range.
$min = $rank - $range;
$max = $rank + $range;
$limit = 10; // max number of results you want.
$query = "select * from table where rank between $min and $max limit $limit";