How to display page views by day, week or month ...`

Discussion in 'Programming' started by drgeorgep, May 29, 2011.

  1. #1
    In mysql, I have a variable, "views," which counts page views for each db entry. "Views" is used to create a variable, in PHP, called "$popular." "$popular" displays db by total since the entry was first made. See the display, on this page, at the top right -- http://grubstreet.ca.

    Is it possible to limit the display to only page views, of a db entry, that occurred today, this week or this month, rather than from day one? If so, where would I find out how to do this, correctly?
     
    drgeorgep, May 29, 2011 IP
  2. x319

    x319 Well-Known Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    103
    #2
    Yes it's possible, but you'll have to record set of views for each year/month/day. Since your not looking to analyze each view, I'd suggest setting up a table structure like:
    
    grub_views:
    ------------------------
    |    gdate   |  views   |
    ------------------------
    | 2011-05-29 |    319   |
    | 2011-05-30 |     19   |
    ------------------------
    
    Code (markup):
    And then retrieve records normally by your choice of either month or by day or by week.
     
    x319, May 29, 2011 IP
  3. drgeorgep

    drgeorgep Active Member

    Messages:
    854
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Hi X ... thanks for your input. I have a variable, "published," whilch is yyyy-mm-dd. From what you write, I suspect I can dispaly by date, date. If true, I can't figure out how to do it. What advice do you offer. Many thanks. dgp
     
    drgeorgep, Jun 2, 2011 IP