JohnnyDoomo Posted October 10, 2013 Share Posted October 10, 2013 Can somebody help me change this line of code: photos WHERE approved=1 AND cat IN (501,511,502,503,562,504,506,505,508,2,510) ORDER BY date DESC LIMIT 10", $link); So that instead of grabbing the 10 latest items of content from my site, it instead grabs 10 random items from only the most recent week? I am a real noob when it comes to php and I'm thinking this can be changed using the rand() command, but I have no idea how to make it so that it only chooses those random items from the past week. Thanks for any help you can provide on this probably simple change. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 10, 2013 Share Posted October 10, 2013 try SELECT * FROM ( SELECT whatever FROM photos WHERE approved=1 AND cat IN (501,511,502,503,562,504,506,505,508,2,510) AND date BETWEEN CURDATE() - INTERVAL 7 DAY AND CURDATE() ) as thisweek ORDER BY RAND() LIMIT 10; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.