voilà la structure du tableau
Code : Tout sélectionner
<form method="post" name="validerclient">
<div class="container">
<table class="styled-table">
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Téléphone</th>
<th>Mail</th>
<th>Quantiter</th>
<th>Supprimer</th>
<th></th>
</tr>
</thead>
<tbody>
<?php if($clients != ""): ?>
<?php foreach ($clients as $client): ?>
<tr>
<td><?= $client['nom'] ?></td>
<td><?= $client['prenom'] ?></td>
<td><?= $client['phone'] ?></td>
<td><?= $client['mail'] ?></td>
<td><?= $client['id_client'] ?></td>
<td><input type="submit" value="Supprimer" name="supprimer"></td>
<td><input type="hidden" name ="client_id" value="<?= $client['id'] ?>" ></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</form>
Code : Tout sélectionner
$clients = $db->query("
SELECT c.id, c.nom, c.prenom, c.phone, c.mail, COUNT(a.id_client) as id_client
FROM client c
LEFT JOIN complet a ON a.id_client = c.id
WHERE a.id_client != ''
GROUP BY c.nom
")->fetchAll();
Code : Tout sélectionner
$delete = $db->query("
DELETE FROM complet
WHERE id_client = $id_client
")->fetchAll();