Jump to content

Recommended Posts

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é.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.