Page 1 of 1

searching large data and paging

Posted: Thu Dec 02, 2004 7:25 am
by nosti
after searching large amount of data and calculating the relevancy of each result i now have a comlete ordered list of results.
the user asked to view the first page of the results which contain 20 results.
that's no problem, but the next pages are.
1st page - 1 to 20
2nd page - 21 - 40
3rd page - 41 - 60
...

How do i implament paging on my results? files? temporary indexed tables?
some better idea?

realy need a lot of help with this, so thank you very very much

Posted: Thu Dec 02, 2004 7:52 am
by CoderGoblin
Suggest you perform a search for Pagination or pages within this forum. This question has been frequently asked and answers provided.

Posted: Fri Dec 03, 2004 2:39 am
by cggreer
There are quite a few tutorials re: pagination around the web, but a quick a dirty way to return the rows as you describe is by using LIMIT in the SELECT statement.

Code: Select all

mysql> SELECT * FROM table LIMIT 20,40;  # Retrieve rows 21-40
This will mean each time someone goes to the 'Next Page >>' you will execute the search again, but will only return the results that correspond to that page (records 21-40 for example).

Links for reference:
MySQL SELECT statement: http://dev.mysql.com/doc/mysql/en/SELECT.html