2
I have a doubt here, not even for the sake of code, but for the sake of what logic.
I have a table with 6000 records in Mysql. I have a PHP script that returns 50 records per page, using SQL’s "LIMIT" function.
Now I need to search a single record of this table and know in which of these "pages" of 50 records it will be.
For example, if it’s record 68, I need to know that it’s on the second page. If it’s 120, on the third and so on.
Is that possible with PHP or Mysql? Could someone give me a light?
Thank you.
When do you need to know this ?
– Diego Souza
@Zoom, is a table with nicknames and player scores, the player will enter the site, inform the nick, based on the nick I will fetch the ID and based on that ID I need to know on page he is. EDIT: The ID part is quiet, I’m just cracking my head with this question of the search there.
– Junior Zancan
Got it. But strange you want to do that. You want to show where he is in the scoring ranking ?
– Diego Souza
Exactly @Zoom, I could easily return only his position with the data and etc. But I wanted to do so described above so that he see "around" his position.
– Junior Zancan
That SELECT:
SELECT @NumRow := @NumRow + 1 As NumeroDaLinha, Nick, ID FROM Users, (SELECT @NumRow := 0) R ORDER BY Pontuacao
places a sequential column in your query. This way you have the user position number. Now you have to do the account to know what page this user is on. I’m bad at math.– Diego Souza
http://answall.com/questions/84265/sistema-de-busca-com-pagina%C3%A7%C3%A3o - Referent?
– João Victor Gomes Moreira
@Zoom, we are two kkkk. But it is precisely this account there that I have no idea how to do.
– Junior Zancan