tHud Posted September 26, 2010 Share Posted September 26, 2010 Hello I would like to be able to 'feature' a certain product every 'x' hours (or perhaps daily). As far as I can see, this seems to work on an 'instantaneous' basis... SELECT * FROM `products` ORDER BY RAND() LIMIT 0,1; Is there a way that I could adapt this to work with a time-frame? Maybe 12 hourly? Or daily? Thanks for looking Link to comment https://forums.phpfreaks.com/topic/214474-selecting-a-random-record-every-x-hours/ Share on other sites More sharing options...
fenway Posted September 27, 2010 Share Posted September 27, 2010 I don't understand -- you want to run the query every X, or the result to be based upon X? Link to comment https://forums.phpfreaks.com/topic/214474-selecting-a-random-record-every-x-hours/#findComment-1116119 Share on other sites More sharing options...
tHud Posted September 27, 2010 Author Share Posted September 27, 2010 Hi Well, I don't really want to involve cron, but it does need to be executed perhaps by the time of day...? (thinking aloud here) So I'm thinking... the result to be based upon X Link to comment https://forums.phpfreaks.com/topic/214474-selecting-a-random-record-every-x-hours/#findComment-1116322 Share on other sites More sharing options...
fenway Posted September 29, 2010 Share Posted September 29, 2010 That still means you want a query to run periodically -- 5.1 has an event scheduler built-in. Link to comment https://forums.phpfreaks.com/topic/214474-selecting-a-random-record-every-x-hours/#findComment-1117154 Share on other sites More sharing options...
tHud Posted September 29, 2010 Author Share Posted September 29, 2010 Thanks for that. Unfortunately, my shared hosting uses MySQL 4.1.22-standard-log - but I will Google it for future reference. Link to comment https://forums.phpfreaks.com/topic/214474-selecting-a-random-record-every-x-hours/#findComment-1117308 Share on other sites More sharing options...
fenway Posted September 30, 2010 Share Posted September 30, 2010 Then cron is your only option. Link to comment https://forums.phpfreaks.com/topic/214474-selecting-a-random-record-every-x-hours/#findComment-1117735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.