Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts

    Addind To a variable at specified times.

    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?

  • #2
    Regular Coder thesmart1's Avatar
    Join Date
    Dec 2005
    Posts
    369
    Thanks
    7
    Thanked 3 Times in 3 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    Thank you for your help!

  • #4
    Regular Coder thesmart1's Avatar
    Join Date
    Dec 2005
    Posts
    369
    Thanks
    7
    Thanked 3 Times in 3 Posts
    No problem.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •