[SOLVED]How can I find out what page a particular record is

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

[SOLVED]How can I find out what page a particular record is

Post by Begby »

I am using record paging with the limit clause and a paginate menu.

What I would like to do is be able to have someone fill in a text box with an identifier, then have the script 'jump' to the page that that identifier appears on.

For instance, if there are 4537 pages with 40 records each, and the user wants to go the page with bin JG16, they won't have to hunt through page after page.

I could implement a search, but I would really prefer to be able to jump to a specific page so that they can continue where they left off if for instance they are spending a week doing inventory and would like to start back where they left off.


The problem is the number of records which is currently about 45,000. I do not want to have to query them all to find out where the record lies. Is this possible to do?
Last edited by Begby on Mon Mar 12, 2007 1:13 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you use the ORDER BY clause you can perform a COUNT() query with a WHERE clause that specifies to look for records lower than "XYZ". Adding one will tell you the exact index. Divide that by the quantity per page (rounding up) and you have the page number.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

feyd wrote:If you use the ORDER BY clause you can perform a COUNT() query with a WHERE clause that specifies to look for records lower than "XYZ". Adding one will tell you the exact index. Divide that by the quantity per page (rounding up) and you have the page number.

You rock! Thanks.
Post Reply