Calculate the page an ID is located on

Asked

Viewed 42 times

0

Assuming I have 10 records and per page shows 3, then the ID 2 will be on the page 1, the ID 7 on the page 3, and so on. In practice I need to access www.dominio.com/lista.php?id=7 page 3, referring to the position of the ID 7.

It is possible to do this in a single query, without having to make a previous query to calculate the position?

  • No hole in your Ids? Never will?

  • @bfavaretto, the most that can occur is status = false to omit a record. The ID will always be there, I just don’t know if the clause status = false affects what you have in mind.

  • If it needs to be omitted from the list when it has such status, yes.

  • I will have to calculate the ID position before paging to play the limit X, Y? I’ll test a subquery.

  • I was thinking of calculating even earlier (a module would solve, considering a list ordered by ID and without holes). But honestly I can’t imagine why you want to do this...

  • @bfavaretto, is a 'jumper' in a comment system where you can jump to a particular comment without having to separate from the others, and continue browsing. Otherwise I need to separate the comment and reshape the display

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.