berry05 Posted December 4, 2008 Share Posted December 4, 2008 like when a field is 100 it increases by 50 every 24 hours...any way i can do that? Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/ Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 Use a timestamp column in the database table. IE column named "nextincrease" and set that to be 24hours from now. The next time it is called you would do if nextincrease < time() then add 50 and set nextincrease = time() + (60*60*24); Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706287 Share on other sites More sharing options...
berry05 Posted December 4, 2008 Author Share Posted December 4, 2008 i made a field called next increase with a timestamp type and entered the code you had and it gave me a error...sorry im kind of new to this.. Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706310 Share on other sites More sharing options...
trq Posted December 4, 2008 Share Posted December 4, 2008 A much more reliable approuch would be to use a cron job to execute a query every 24 hours. Check to see if your hosting supports cron jobs. Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706312 Share on other sites More sharing options...
berry05 Posted December 4, 2008 Author Share Posted December 4, 2008 cron jobs..ill try that...btw i am the host Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706327 Share on other sites More sharing options...
trq Posted December 4, 2008 Share Posted December 4, 2008 cron jobs..ill try that...btw i am the host Then you should know what a cron job is (assuming your using Linux). Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706329 Share on other sites More sharing options...
berry05 Posted December 4, 2008 Author Share Posted December 4, 2008 negative...im using windows..btw can someone make me a cron job that increases the field gold by 50 every 24 hours? xD Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706336 Share on other sites More sharing options...
trq Posted December 4, 2008 Share Posted December 4, 2008 cron doesn't run on windows. You'll need to use windows scheduler. Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706342 Share on other sites More sharing options...
berry05 Posted December 4, 2008 Author Share Posted December 4, 2008 thank you! i'll check it out! Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706343 Share on other sites More sharing options...
berry05 Posted December 4, 2008 Author Share Posted December 4, 2008 one more last thing..is there a php code that if i open it it updates the field and adds 100 so i can do the task manager to open the file every 24 hours so the field gets 100 more every 24 hours? Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706347 Share on other sites More sharing options...
trq Posted December 5, 2008 Share Posted December 5, 2008 <?php // connect to database here. mysql_query("UPDATE tbl SET fld = fld+100"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-706381 Share on other sites More sharing options...
berry05 Posted December 5, 2008 Author Share Posted December 5, 2008 wow how do you know all this!! thxs man! Quote Link to comment https://forums.phpfreaks.com/topic/135575-solved-how-to-add-value-to-a-filed-every-24-hours/#findComment-707155 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.