#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    Iran
    Posts
    44
    Rep Power
    11

    Paginate rows day by day in PHP/MySQL


    I have a MySQL query that returns rows containing date_add column like below:
    Code:
    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?
  2. #2
  3. Anemic Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,803
    Rep Power
    9432
    Code:
    WHERE DATE(date_add) = "desired date"
    Code:
    WHERE date_add BETWEEN "desired date 00:00:00" AND "desired date 23:59:59"
    (giving you both because I'm not sure of the performance; common sense says the latter is better but MySQL might be smart enough to optimize the first one into the second)

    It's just a(nother) condition to add to your query. No LIMITs. The only thing that makes it "pagination" is that you're restricting what shows up on a page and giving the user the option (eg, a link) to move to another page.

IMN logo majestic logo threadwatch logo seochat tools logo