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.