CodeIgniter Forums
Data randomizer? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Data randomizer? (/showthread.php?tid=71219)



Data randomizer? - kaitenz - 07-19-2018

Hi,

I need some idea for the randomizer. This will run on a cron job. What I want  to do is the script will pick 3 random rows from the database that marked as "not_started" then assign to one user. Then repeat that process until all users have assigned tickets.

This will happen from Monday to Friday. If the user only had 2 assigned tickets on Monday, the tool will attempt to assign 4 tickets for Tuesday (remember, 3 random rows per day, here since only 2 have assigned to the user, the remaining 1 will be summed for Tuesday) and so on..

If on Tuesday, the app only assigned 2 tickets, it will attempt to add 5 tickets for Wednesday.

Hope you understand my problem and hope someone can help me.

Thanks.


RE: Data randomizer? - nalletje - 07-20-2018

Do you use MySQL?

In that case you could do that with your query.

SELECT * FROM `TABLE` WHERE `FIELD` = 'NOT_STARTED' ORDER BY RAND() LIMIT 3