Is there a way to have mysql pick a random topic once per day? I can get it to randomly do it each time the page is refreshed but I would like for it to select something randomly every 24 hours or so?
Thanks in advance🆒
use date() and rand()
veeery ot, but I love your sig toddmarx😃
Ok, I going to show a little ingnorance:eek: .
I have read the above links on rand() and date(), but I just dont see how to get it to do what I want. But I still dont get it. 😕
A little more help please. 🙂
Something like:
if(date("hisa") == 120000am){ //pick a random topic } else { //dont pick a random topic }
Don't feel ignorant, I know that because the date() thing is SO FUN! :-D
I dont think that is what I am looking for, I want mysql to pick a product from a table at random once per day. I understand the date and random commands, just not how to put them together in a mysql query. 🙂
make a new table.... randomItem updated=int (store unixtimestamp here) itemID=store the id of the random item here...
do a check
if (date('y-m-d') != date('y-m-d',$timestampfromrandomItemtable)) { //update random item, dont forget to update the updated field too so that you know its a new days item.. } //do nothing and go on to the rest of the page to do whatever with the current days random item