par
thirt05 » 20 mai 2020, 18:48
Bonjour Saian,
merci pour votre réponse.
En effet, j'ai déjà pensé à cette solution mais le problème, c'est que j'ai une liste de produits avec des identifiants différents.
Donc, on peut cliquer sur le produit avec l'identifiant 1 ou l'identifiant 127. Le problème, c'est que ça vient de la base de données et que c'est dynamique. Donc, je ne sais pas comment je peux faire pour récupérer l'Id du produit sur lequel l'utilisateur a cliqué sur le bouton supprimer qui lui correspond.
Voici mon code :
<h3>Listing des produits</h3>
<form action="panel.php" method="post" role="form">
<table>
<thead>
<tr>
<th>Libellé</th>
<th>Description</th>
<th>Prix</th>
<th>Disponible</th>
<th>Modifier</th>
<th>Supprimer</th>
</tr>
</thead>
<tbody>
<?
if ($count_products === 0)
{
?>
<tr>
<td colspan="7">Aucun produit trouvé ...</td>
</tr>
<?
}
else
{
foreach ($products as $product)
{
?>
<tr>
<td data-column="Libellé"><?= $product->Libelle; ?></td>
<td data-column="Description"><?= $product->Description; ?></td>
<td data-column="Prix"><?= $product->Prix; ?></td>
<td data-column="Disponible">
<?
if ($product->Disponible == 1)
{
echo "Oui";
}
else
{
echo "Non";
}
?>
</td>
<td data-column="Modifier">
<a href="update.php?id=<?= $product->Id; ?>×tamp=<?= $product->CreationDate; ?>"><img src="images/pensil-icon.png" alt="modifier" class="img-update" /></a>
</td>
<td data-column="Supprimer">
<input type="submit" class="deleteProduct" name="btnDeleteProduct" value="Supprimer" />
</td>
</tr>
<?
}
}
?>
</tbody>
</table>
</form>
Merci d'avance
Bonne soirée
Thierry
Bonjour Saian,
merci pour votre réponse.
En effet, j'ai déjà pensé à cette solution mais le problème, c'est que j'ai une liste de produits avec des identifiants différents.
Donc, on peut cliquer sur le produit avec l'identifiant 1 ou l'identifiant 127. Le problème, c'est que ça vient de la base de données et que c'est dynamique. Donc, je ne sais pas comment je peux faire pour récupérer l'Id du produit sur lequel l'utilisateur a cliqué sur le bouton supprimer qui lui correspond.
Voici mon code :
[PHP]
<h3>Listing des produits</h3>
<form action="panel.php" method="post" role="form">
<table>
<thead>
<tr>
<th>Libellé</th>
<th>Description</th>
<th>Prix</th>
<th>Disponible</th>
<th>Modifier</th>
<th>Supprimer</th>
</tr>
</thead>
<tbody>
<?
if ($count_products === 0)
{
?>
<tr>
<td colspan="7">Aucun produit trouvé ...</td>
</tr>
<?
}
else
{
foreach ($products as $product)
{
?>
<tr>
<td data-column="Libellé"><?= $product->Libelle; ?></td>
<td data-column="Description"><?= $product->Description; ?></td>
<td data-column="Prix"><?= $product->Prix; ?></td>
<td data-column="Disponible">
<?
if ($product->Disponible == 1)
{
echo "Oui";
}
else
{
echo "Non";
}
?>
</td>
<td data-column="Modifier">
<a href="update.php?id=<?= $product->Id; ?>×tamp=<?= $product->CreationDate; ?>"><img src="images/pensil-icon.png" alt="modifier" class="img-update" /></a>
</td>
<td data-column="Supprimer">
<input type="submit" class="deleteProduct" name="btnDeleteProduct" value="Supprimer" />
</td>
</tr>
<?
}
}
?>
</tbody>
</table>
</form>
[/PHP]
Merci d'avance
Bonne soirée
Thierry