У меня проблема, когда я хочу удалить строку, она удаляет только первую, я использую модал php и bootstrap
ajout.php на этой странице я вызываю deleteEntreprise.php с идентификатором
$pdo = new PDO('mysql:dbname=test;host=localhost','root','root');
$pdoStat = $pdo->prepare('SELECT * FROM entreprise');
$ExecuteIsOk = $pdoStat->execute();
$entreprises = $pdoStat->fetchAll()
<?php foreach ($entreprises as $entreprise): ?>
<tbody>
<tr>
<td >
<?= $entreprise['id'] ?>
</td>
<td>
<a href="liste.php?id=<?= $entreprise['id'] ?>" style="text-decoration : none !important; color : white !important;"><?= $entreprise['nom'] ?></a>
</td>
<td>
<button type="button" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#exampleModal">Supprimer
</button>
</td>
</tbody>
</tr>
<div class="modal fade" id="exampleModal" tabindex="0" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">ATTENTION !</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Etes-vous sûr(e) de vouloir supprimer le compte ?
</div>
<div class="modal-footer">
<button type="button" class="btn-sm btn-secondary" data-dismiss="modal">Fermer</button>
<a href="deleteEntreprise.php?id=<?= $entreprise['id'] ?>" class="btn btn-danger btn-sm active" role="button" aria-pressed="true">Supprimer le compte</a>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</table>
deleteEntreprise.php sql-запрос для удаления предприятия
<?php
// Cette fonction permet de supprimer une fiche entreprise de la base données
$entreprise_id = $_GET['id'];
require 'inc/db.php';
$req = $pdo->prepare('SELECT * FROM entreprise WHERE id = ?');
$req->execute([$entreprise_id]);
$user = $req->fetch();
session_start();
$pdo->prepare('DELETE FROM entreprise WHERE id = ? ')->execute([$entreprise_id]);
$_SESSION['flash']['success'] = 'Lentreprise a bien été supprimer de la base de données.';
// $_SESSION['auth'] = $user;
header('Location: ajout.php');
exit();
Я надеюсь, что предоставил достаточно информации, чтобы помочь решить мою проблему.
Любая помощь будет принята с благодарностью!
Спасибо и хорошего дня!