Fonction php dans un href avec paramètre
Bonjour,
Je possède un fichier pdoProduit.php qui regroupe plusieurs fonctions et un fichier V_produit_consult.php.
Dans un foreach , j'affiche les attribut de chaque objet produit.
J'aimerais supprimer le produit de mon tableau via ma fonction php 'deleteProduit($objProduit)'.
La fonction fonctionne, mon problème est la syntaxe, je n'arrive pas à parrtir d'un <href> rediriger vers mon fichier 'pdoProduit.php' et cibler ma fonction 'deleteProduit($objProduit)'.
Quelqu'un aurait il une idée?
Je vous remercie.
V_produit_consult.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
foreach ($objProdCateg as $objProd) {
// $obj = PdoProduit::getUnProduit($objProd->getId());
?>
<tr>
<td><?php echo $objProd->getId() ?></td>
<td><?php echo $objProd->getLibelle() ?></td>
<td><?php echo $objProd->getPrix() ?></td>
<td><?php echo $objProd->prixTTC() ?></td>
<td><?php echo $objProd->getObjCateg()->getID() ?></td>
<td><?php echo $objProd->getObjCateg()->getlibelle() ?></td>
<td><a href=" " onclick="confirm('oki?')" >bouh</a> </td> // appel de la fonction deleteProduit($objProduit)
</tr>
<?
}
?> |
pdoProduit.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
public static function deleteProduit($objProduit)
{
try {
$c = $objProduit->getId();
$objPdo = PdoConnexion::getPdoConnexion();
$req = "DELETE from produit where pr_id = $c";
$objPdo->exec($req);
return true;
} catch (Exception $ex) {
return false;
}
} |