Page 1 of 1

PHP & Cron

Posted: Fri Feb 18, 2005 10:56 pm
by SilverMist
Hey guys,
Does anyone know how to make a cronjob randomly pick a set number of items in a database? Like say if people enter a competition, it puts it in a table, then at whatever time the cronjob is set to it randomly picks six of those entries? I have absolutely zero insight so any tips and I would be deeply grateful.

Posted: Fri Feb 18, 2005 11:15 pm
by feyd

Code: Select all

SELECT * FROM table ORDER BY RAND() LIMIT 6

Posted: Sat Feb 19, 2005 12:08 am
by SilverMist
But feyd-o wouldn't that just get the first six entries?

Posted: Sat Feb 19, 2005 12:11 am
by feyd
'order by rand()' selects random ordering of the records available.