Page 1 of 1
Update Automatically?
Posted: Mon Jul 11, 2005 8:12 am
by Dale
How would i get an UPDATE command to run every 24hours automatically?
Code: Select all
$sql = "UPDATE points SET points = points + 15";
^ How would i get it so that everyone in my database gets 15 points every 24 hours automatically? Is it a cron job or something, if so, how would i run that?
Posted: Mon Jul 11, 2005 8:33 am
by onion2k
Theres 2 ways.
1. Use a cron job. Basically you'd write a script to do the update, then add a cron task to cron on the server. If you've got CPanel or something similar you should have a handy interface, else ask the admin.
2. Add to the index.php of the site something that updates a date to tomorrows date in a database somewhere. Each time the script runs it should check the date, if it's the current date, update all the scores and set the database date to tomorrow again.
Two problems with the second way: 1. It's a hit on the database every time the index loads, and 2: it won't update the scores if noone visits the site.
Posted: Mon Jul 11, 2005 8:36 am
by Dale
I might just go with option 2, and have something in the database that checks if the daily update has been made.
