I am building an online game (something similar to [url removed, login to view] but different). I have most of what I need working but there is an upgrade section where I need a countdown timer to work together with a mysql backend. I have the recording of times working properly, but I need a timer to calculate how long is left in the upgrade. As soon as one upgrade is started no other upgrade should be selectable and when the counter reaches zero there needs to be a update to the database with the upgraded stats for the item upgraded. Furthermore it needs to continue counting down when a person is offline and the upgrade still needs to happen if they are offline when the timer runs out. While the person is logged in they need to be able to see that the countdown is running without refreshing the page.
Database calls can be generic and I can add the code to which table will be modified.
variables can be generic and I will update them with what I have.
Countdown should take seconds as a variable and convert it to days, hours, minutes and seconds.