I am trying to sort the table by the reputation and then select the position of the row [rank], it works fine, but I would like to print out 3 tables above and 3 tables below this rank row, but LIMIT rank,6 does not work :/ (Im sorry for that wrong formatted SQL :/) Would be thankful for every help :)
Here is what is working:
$query = mysqli_query($con, "SET @rank=0");
$query = mysqli_query($con, "
SELECT
rank,
user_email,
reputation
FROM (
SELECT
@rank:=@rank+1 AS rank,
user_email,
reputation
FROM accounts, (SELECT @rank := 0) r
ORDER BY
reputation DESC
LIMIT 0,7
) t
WHERE
reputation >= '5'
OR reputation < '5'");
prints
[rank] [user_email] [reputation]
1 mail1@gmail.com 20
2 test@test.com 15
3 mail2@gmail.com 10
4 othermail@gmail.com 5
5 hmmmmm@gmail.com 0
6 ouch@gmail.com 0
7 somemail@gmail.com 0