MySQLのbetween
を利用できます およびlimit
このための条項:
$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";