diff --git a/poker-paf/delete_game.php b/poker-paf/delete_game.php index 7e8cb6a..d1237cc 100644 --- a/poker-paf/delete_game.php +++ b/poker-paf/delete_game.php @@ -10,6 +10,10 @@ header('Content-Type: application/json'); if ($game_id) { $stmt = $db->prepare("DELETE FROM games WHERE id = ?"); $stmt->execute([$game_id]); + + // Supprimer les joueurs associés à la partie + $stmt = $db->prepare("DELETE FROM players WHERE game_id = ?"); + $stmt->execute([$game_id]); } else { echo "Aucune partie à supprimer."; exit; diff --git a/poker-paf/game.php b/poker-paf/game.php index 3f2792a..dfaf325 100644 --- a/poker-paf/game.php +++ b/poker-paf/game.php @@ -59,7 +59,7 @@ foreach ($players as $p) {
POT TOTAL: 🪙
MISE ACTUELLE:
- + ⬅ Quitter
@@ -305,11 +305,11 @@ foreach ($players as $p) { }); } - function deleteGame(idPartie) { + function deleteGame() { if (confirm("Supprimer la partie ?")) { let formData = new FormData(); - formData.append('game_id', idPartie); - console.log("Suppression de la partie ID:", idPartie); + formData.append('game_id', actualGameID); + console.log("Suppression de la partie ID:", actualGameID); fetch('delete_game.php', { method: 'POST', body: formData }) .then(() => window.location.href = 'index.php');