Web Analytics Made Easy -
StatCounter display result of last 30 days - CodingForum


No announcement yet.

display result of last 30 days

  • Filter
  • Time
  • Show
Clear All
new posts

  • display result of last 30 days

    I have a post table that has some of these fields:
    i want to query the number of posts that happened in the last 30 days and display the date.i.e display posts that happened on each date and the also display the date.
    POSTS 10 1/9/2011
    POSTS 20 31/8/2011

    i know i can do a select postid and then do a mysql_num_rows to get the number of posts. But I am not sure how to get the result of last 30 days and display that date. Here is my table structure
    postid username userid title dateline
    1 test 3 member 1186945212
    3 tester 5 JM 1187106827

  • #2
    Just calculate the timestamp that would be from 30 days ago (use strtotime() for this) and search for all entries greater than that:

    PHP Code:
    $limit strtotime("-1 month");
    $query="SELECT * FROM table WHERE timestamp > $limit"
    I am guessing at your names for the table and for the timestamp column. Replace those with the correct names and this should work.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting