Jump to content

Paginate rows day by day in PHP/MySQL


silvercover

Recommended Posts

I have a MySQL query that returns rows containing date_add column like below:

DATE(date_add)
2014-01-07
2014-01-07
2014-01-07
2014-01-07
2014-01-08
2014-01-15
2014-01-20
2014-01-20
2014-01-20
2014-01-26
2014-01-28
2014-02-16
2014-02-16
2014-02-16
2014-02-16
2014-02-16
2014-02-16
2014-02-16
2014-02-18
2014-02-18
2014-03-08
2014-03-08

How can I have pagination based on dates and show rows with the same date in a page and not just based on predefined limit number?

Link to comment
Share on other sites

you would actually do 'date-ination', where your links cause specific or next/previous dates to be selected, not logical page numbers.

 

you can get a unique list of distinct dates and make a link for each one, displaying only the first one, a small range around the currently selected date, and the last one and/or you can make links with the currently selected date and a next/previous flag that would query for the next highest or lowest date from the selected date.

 

if your dates can have a large number of results for any day, you may still want to have traditional pagination for the results. your links would just be built with the 'date-ination' selection and the logical page numbers for the pagination.

Link to comment
Share on other sites

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.