PHP & Cron

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

PHP & Cron

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

SELECT * FROM table ORDER BY RAND() LIMIT 6
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

But feyd-o wouldn't that just get the first six entries?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

'order by rand()' selects random ordering of the records available.
Post Reply