$sql = "Select photos.*, categories.cat FROM photos, categories
WHERE photos.cat_id = categories.id AND photos.status ='1' ORDER BY (videos.up-videos.down) DESC
LIMIT $start, $limit";
$result = mysql_query($sql);
The photos table contains one column called "dateposted' which is in the following format (2010-08-03 00:15:00).
How do I from this query select different timeframes by using "hours" something like this I am guessing??:
Day
WHERE dateposted=time(now)-24(hours)
Week
WHERE dateposted=time(now)-168(hours)
Month
WHERE dateposted=time(now)-744(hours)
Year
WHERE dateposted=time(now)-8760(hours)
$sql = "Select videos.*, categories.cat FROM videos, categories
WHERE videos.cat_id = categories.id AND photos.status ='1' AND DATE_SUB(videos.dateposted, INTERVAL 24 HOUR) ORDER BY (videos.up-videos.down) DESC
LIMIT $start, $limit";
$result = mysql_query($sql);
I have tried this but it still selects all videos instead of the past 24 hours.. Thanks!
Last edited by defroster on Mon Aug 09, 2010 4:48 am, edited 1 time in total.