Okay… I’m lost (again). How can I make a custom seed for rand() that will keep the pick from the database for a specific period of time: 10 minutes, 1 hours, 1 day, etc.
I use this:
$query = 'SELECT * FROM table order by rand () LIMIT 1';
To get a random pick every time I refresh the page. I’ve been reading for days, but I just can’t find an example that explains how to make a custom seed that will keep the selection for a specific period of time. Please help me… sighs
As Dominic Rodger said – order by rand is horrible.
But I find using cron too big a gun for the job. (especially that You don’t know how)
You should rather generate a random integer number in php and store it and pass it to the mysql to something like that:
it gets a big random number and does modulo, so that it doesnt go over the table length.
This has a problem with
LAST_INSERT_ID()though. Your mysql may return 0 there in many cases.So the good’n’safe way to do that would be:
and do only select where id=$sth