lopes_andre Posted April 12, 2009 Share Posted April 12, 2009 Hi, I'am with some trouble to paginate search results... Do you have some example on How to paginate search's in PHP? Best Regards, André. Quote Link to comment https://forums.phpfreaks.com/topic/153746-how-to-paginate-a-search/ Share on other sites More sharing options...
premiso Posted April 12, 2009 Share Posted April 12, 2009 http://www.phpfreaks.com/tutorial/basic-pagination Take a look at the tutorial on pagination. Quote Link to comment https://forums.phpfreaks.com/topic/153746-how-to-paginate-a-search/#findComment-807984 Share on other sites More sharing options...
jackpf Posted April 12, 2009 Share Posted April 12, 2009 Beat me to it Quote Link to comment https://forums.phpfreaks.com/topic/153746-how-to-paginate-a-search/#findComment-807985 Share on other sites More sharing options...
lopes_andre Posted April 12, 2009 Author Share Posted April 12, 2009 http://www.phpfreaks.com/tutorial/basic-pagination Take a look at the tutorial on pagination. Thanks for your reply. I'am using a script like this. My problem is the following: I have a complex code that generate an SQL query, but when I go to page 2 or 3 or ... I lost the query... My question, how to deal with a page that receives values from a form then generates a query... how to paginate in a situation like this one. form --> generate sql query --> show results in pages. Sorry for my bad english. Best Regards, André. Quote Link to comment https://forums.phpfreaks.com/topic/153746-how-to-paginate-a-search/#findComment-808037 Share on other sites More sharing options...
.josh Posted April 12, 2009 Share Posted April 12, 2009 can't help you without seeing your (relevant) code... in general though, the query will have to be run every page load. The point of pagination is that instead of retrieving all of your rows every page load, you narrow it down to a specific range, depending on what "page" you are on. So if you want to for instance show 10 rows per page, and you are on page 1, the query will be the same, but you would create a limit of 0,9. Page 2 would be a limit of 10,19, etc... so the same query is being run, just the limit is changing. If it is a complex query that you do not want to be running every time, I would suggest looking into either initially grabbing the data and putting it into a flatfile or array and basing the pagination off of the flatfile or array (instead of querying the db every time), or having another (temporary) table in your database that is populated with the results of the initial query, and basing your pagination off that. Quote Link to comment https://forums.phpfreaks.com/topic/153746-how-to-paginate-a-search/#findComment-808041 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.