I need help because my script does not work as I would like
Basically, I create a loop that if "$temporairesoldat> 0" runs a counter of 240second and at the end of this counter increments +1 in the "soldat" table and -1 in the "temporairesoldat" table and when "$temporairesoldat <= 0 "is over.
<script>
var compte = 240;
function decompte()
{
    if(compte <= 1) {
        pluriel = "";
    } else {
        pluriel = "s";
    }
    document.getElementById("compt").innerHTML = compte + " seconde" + pluriel;
    if(compte == 0 || compte < 0) {
        compte = 0;
        '<?php $bdd->prepare(" UPDATE caserne SET soldat=soldat+1, temporairesoldat=temporairesoldat-1 "); ?>'
        clearInterval(timer);
    }
    compte--;
}
var timer = setInterval('decompte()',1000);
</script>
<span id="compt"></span>
 
    