...

View Full Version : Addind To a variable at specified times.



srule_
08-09-2007, 01:57 AM
Hi.

Lets say i have a variable --> $count = '100';

now every 10 minuts i want $count to increase by 10, for a maximum of 3000.

any suggestions on how i can do this?

thesmart1
08-09-2007, 02:41 AM
Put simply: you can't do that in PHP. PHP is processed on the server, before the page reaches the browser, and then it's never processed again (unless of course the user reloads/refreshes the page). You'd need to use JavaScript for that.

However, there is a way you could do it, I guess. You could create a session (or just make a cookie), save the variable to that, then using a meta redirect and/or JavaScript, reload the page. Then have the PHP increment the variable as needed.

But I would still definitely recommend that you just use JavaScript. Use setTimeout (http://www.w3schools.com/js/js_timing.asp).

srule_
08-09-2007, 03:02 AM
Thank you for your help!

thesmart1
08-09-2007, 03:17 AM
No problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum