bonsoir!
voilà j'aimerais supprimer des articles dans mon panier
voici le code de mon panier :
<?
include ("definitioninfo.php");
include ("aff_panier.inc.php");
if (!session_id())
session_start();
if (!isset($_SESSION['panier'])) //$panier pas defini //sert pour la gestion du panier
{ //ne pas tenir compte pr le moment
$panier = array (
"ref_produit" => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23),
"quantite" => array (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
);
$_SESSION['panier'] = $panier;
$_SESSION['total'] = 0;
}
session_register('article');
session_register('prix');
session_register('quantite');
session_register('ref_produit');
//$_POST['quantite']= $_SESSION['quantite'];
// $_POST['article'] = $_SESSION['article'];
for ($i = 0; $i < 23; $i++) //pr le panier
{
//echo("article : ".$_SESSION['panier']['ref_produit'][$i]);
//echo(" quantite : ".$_SESSION['panier']['quantite'][$i]."
");
}
$quantite = $_POST['quantite'];
$article = $_POST['article'];
///echo "quantite post = ".$quantite;
if(!($base=mysql_connect("localhost","root","pouet")))
{
echo "
probleme lors de la connexion à MySql
";
exit();
}
else
{
mysql_select_db(BASE, $base);
if (($tab_com = mysql_query("SELECT ref_produit, designation_produit, prix_produit
FROM produit
WHERE designation_produit = '".$article."'", $base)))
$res_com = mysql_fetch_array($tab_com); //tableau contenant les valeurs de la requete (resultat_commande)
}
$_SESSION['article'] = $res_com[1];
$_SESSION['prix'] = $res_com[2];
$_SESSION['quantite'] = $quantite;
$_SESSION['ref_produit']= $res_com[0];
//$_SESSION['panier']['quantite'][$_SESSION['ref_produit']]++; //pr le panier
$_SESSION['panier']['quantite'][$_SESSION['ref_produit']] = $_SESSION['panier']['quantite'][$_SESSION['ref_produit']]+$quantite;
$_SESSION['total'] = $_SESSION['total']+($res_com[2]*$quantite);
//$_SESSION['TTC'] = $_SESSION['total']+ $_SESSION['total']*(19.6/100); // à aligner a droite
echo "<html>
<head>
<title>Bienvenue sur materiel-informatique.fr</title></head>
Votre Panier de Commande :
<form method = "POST" action="[Supprimer');
}
if(!($base=mysql_connect("localhost","root","pouet")))
{
echo "
probleme lors de la connexion à MySql
";
exit();
}
else
{
mysql_select_db(BASE, $base);
for ($i = 1; $i <= 23 ; $i++)
{
if (($tab_com = mysql_query("SELECT ref_produit, designation_produit, prix_produit
FROM produit
WHERE ref_produit = '".$_SESSION['panier']['ref_produit'][$i]."'
AND '".$_SESSION['panier']['quantite'][$i]."' > 0", $base)))
$res_com = mysql_fetch_array($tab_com); //tableau contenant les valeurs de la requete (resultat_commande)
//print_r ($res_com);
// si envoi de formulaire
if(isset($_POST['sub_form'])) {
// si suppression
if($_POST['sub_form']=="supprimer") {
$sql "DELETE FROM produit WHERE ref_produit '".$_SESSION['panier']['ref_produit']."'";
$res = mysql_query($sql) or die (mysql_error());
}
}
$quantite = $_SESSION['panier']['quantite'][$i];
$prix = $res_com[2]*$quantite;
if ($quantite > 0)
{
echo " <tr align="center">
<td> ".$res_com[0]." </td>
<td>".$res_com[1]."</td>
<td>".$res_com[2]."</td>
<td>".$quantite."</td>
<td>".$prix." ?</td>
<td></td>
<td></td>
</tr>";
}
}
}
}
//<form method POST action 'supprime.php'>
//
//
//</form>
//
//onClick='alert("voullez vous vraiment supprimer?")'>
?>
merci pour votre aide...