joel2k8 Posted September 23, 2008 Share Posted September 23, 2008 Well hello everyone, What I am trying to do is update a query using time or date instead off using Cronjobs. Like if I want to update a query every 5mins what would be the best thing I could do? I have tried things such as: if ((date('s')) == 300) { mysql_query("UPDATE users SET money = money + 1000"); } Yes it does work accept you have to refresh on the exact time to get the money, but I want to update the users without everybody refreshing because if they don't refresh it wont update :-\ I have tried different things but I'm not good when it comes to time and date. Any suggestions?... thanks if you help me out Quote Link to comment Share on other sites More sharing options...
jonsjava Posted September 23, 2008 Share Posted September 23, 2008 you gotta execute the script for it to run. It's not a program that will run in the background all the time. CRON is the only way I can think of. Quote Link to comment Share on other sites More sharing options...
discomatt Posted September 23, 2008 Share Posted September 23, 2008 You can simply store a last updated time somewhere... and on every page request check that time... if it was more than 5 minutes ago, perform the update function and update the time. Quote Link to comment 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.