The idea is pretty simple:

Where the timer is made in Javascript, when it reaches zero it performs a query in PHP that alters the database value to add 1.

The problem is that the timer in question must not be reset with page refresh, just like any browser based game, when you build a new facility.

This is for a school game project, in which you click "Build" and depending on that facility's level it would take X time to upgrade it to a new level, showing a timer that tells the user how much time left until the upgrade is done.

I'm really sorry if the solution is somewhere here, but I swear to god I've searched everywhere but I could not get a decent methodology to do this.

Hi El Pirata,

When the timer is activated, you could store a unix timestamp in a php session. Then if/when the user refreshes the page, you can check for a session (with the start time value) and continue counting down from there.

Hope this helps.

Jim :)

Adding on to Jim's reply, you would also need to calculate the (current time - time stored in session). This would give you the amount of time that the user has been playing. Deduct that from the total time to get the time remaining before the timer reaches 0.