I'm working on a simple button that will allows to increment a line in my table. Thanks to AJAX, when the button +1 is clicked, it is replaced by a -1 button. But the problem occurs when I click once on +1, then -1 and a second time on +1.
$requete = $bdd->prepare('UPDATE vote SET nb_vote = nb_vote + 1 WHERE ID_member = :ID_member');
$requete->execute(array('ID_member' => $member_ID));
$requete->closeCursor();
DELETE.PHP is the same as above, just replace nb_vote + 1 with nb_vote - 1
DELETE.PHP与上面相同,只需用nb_vote - 1替换nb_vote + 1
This problem only happens when I don't reload the page. If I reload the page after each click on the button, there is no problem. So I think that the problem is due to the fact that since there is no page reloading, nb_vote kept the old value but that doesn't explain why it goes back to 0 after that...