jquery ajax pagination with php question
First off I would like to say that I have done ample research on jquery pagination tutorials and scripts and the ones I have tried had worked, but just not the way I wanted them to.
What I am looking for is a jquery+php pagination that has 5 buttons. One for the first page, last page, next page, previous page, and manually enter a page to go to (which would also display the current page). I am new to pagination and have no idea how to integrate or alter current scripts, but I'm willing to learn as long as I can have the 5 buttons stated above and use php mysql queries. Thanks for the help!
UPDATE: I can do this with only php (would have to reload the page) but I do not know how to do thi开发者_JAVA技巧s with jquery
UPDATE2: I figured out how to have the user manually input page number, but I still do not know how to do the other for buttons. For the next and previous buttons, I think I need to return the current page, but I have no idea how to do this :/
The trick is you use limit and offset parameters in your mysql query. Depending on what page number of the result you are serving, you can modify the ordered mysql query to fetch the result from that offset. It's pretty simple to work with that after you understand how to paginate in mysql queries.
In order to accomplish this you simply need to enable your application to make an ajax call to fetch the 'more info' results. That ajax call should take two parameters, an OFFSET and a LIMIT. Simply store these values locally in the application (via hidden elements, JS cookies, etc) to reference. Next time the 'more info' button is pressed you increment the OFFSET by the LIMIT and repeat.
NOTE: It's important that your query that is fetching the results is also using an ORDER BY. If you are relying on the server to order the results the same automatically you could potentially repeat results if the data is being updated often.
精彩评论