View Full Version : display result of last 30 days

09-01-2011, 07:16 PM
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

09-01-2011, 08:07 PM
Just calculate the timestamp that would be from 30 days ago (use strtotime() (http://us3.php.net/manual/en/function.strtotime.php) for this) and search for all entries greater than that:

$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.