RichterBelmont Posted May 17, 2009 Share Posted May 17, 2009 I'm looking for a way to edit an SQL tables data automatically. Sort of a loop that randomly edits a specific field within a given range. I need every number within that field to randomize itself every hour, but within a given range/average. Each line within the table will also need its own specific range/average. So lets say the the table is this: Name Id Number Alex 1000 Tim 4000 Nick 8000 I'd want it to automatically update and change itself to something like this: Alex (Random number between 0-2000) Tim (Random number between 3000-5000) Nick (Random number between 7000-9000) I'm assuming i need to use PHP for this and have it constantly looping this script every so often, and/or possibly running a server to update and edit these fields regularly. Any advice of any kind would be greatly appreciated. Even a name to what this process would be called so i at least have something to search for. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/158479-automaticaly-randomize-data-within-a-table/ Share on other sites More sharing options...
Mchl Posted May 17, 2009 Share Posted May 17, 2009 cron job for scheduling a script to run MySQL's rand function for generating random values. You could also use php rand Quote Link to comment https://forums.phpfreaks.com/topic/158479-automaticaly-randomize-data-within-a-table/#findComment-835799 Share on other sites More sharing options...
RichterBelmont Posted May 17, 2009 Author Share Posted May 17, 2009 What if i wanted the randomly generated values to only randomly generate values in increments of 100. so 1000, 1100, 1700 etc... Quote Link to comment https://forums.phpfreaks.com/topic/158479-automaticaly-randomize-data-within-a-table/#findComment-836065 Share on other sites More sharing options...
RichterBelmont Posted May 18, 2009 Author Share Posted May 18, 2009 Sorry to double post but i think i answered my own question. All i have to do is generate a smaller number and then multiply it by 100. The table data is hosted on my server is there a way to automatically run the script every hour within mysql? Like could i set the script to run and randomize the table every day at 12:30 pm? Again sorry for the double post and being a total noob. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/158479-automaticaly-randomize-data-within-a-table/#findComment-836076 Share on other sites More sharing options...
Mchl Posted May 18, 2009 Share Posted May 18, 2009 MySQL 5.1 and later has scheduler you can use for that http://dev.mysql.com/doc/refman/5.1/en/events.html If not, you can use cron jobs http://en.wikipedia.org/wiki/Cron Quote Link to comment https://forums.phpfreaks.com/topic/158479-automaticaly-randomize-data-within-a-table/#findComment-836223 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.