[PHP-JS] modif quantite article dans panier
bonjour !
j'ai un soucis avec mon panier
ché pas quand je veux modifier la quantité d' un article et que j'ai plusieurs articles dans mon panier, que je veux modifier la quantite de mon premier article, ça me modifie la quantite de mon dernier
jpige pas
voici mon code
(page de mon panier)
panieressai1.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
<?
error_reporting(E_ALL);
session_start();
echo "<html>
<title>Annulation</title>
<body bgcolor = #CCCCCC>
<p align = center><b><u><font size = +2>Annulation commande </p></u></font>";
if(!($base=mysql_connect("localhost","root","oyé")))
{
echo "<br><B>probleme lors de la connexion à MySql</B><br>";
exit();
}
else
{
mysql_select_db("bd", $base);
$sql = "SELECT ref_produit, quantite, total_produit FROM panier2 WHERE id_cli = '1' ";
$res = mysql_query($sql) or die(mysql_error());
// formulaire
echo"<center>";
echo "<form method='post' action='panieressai2.php'>";
echo "<table border ='1' cellpadding='1' cellspacing='0' bordercolor='black'>";
echo "<tr>";
echo "<td><center><b>Réference</center></b></td>";
echo "<td><center><b>Quantite</center></b></td>";
echo "<td><center><b>Total produit</center></b></td>";
echo "<td><center><b>Modif</center></b></td>";
echo "<td><center><img src = corbeille.GIF></center></td>";
echo "</tr>";
while($data = mysql_fetch_array($res))
{
echo $data['ref_produit']."Reference<br>";
$_SESSION['ref_produit'] = $data['ref_produit'];
echo "<tr>";
//echo "<input type='hidden' name= 'ref_produit' value='".$data['ref_produit']."' />";
echo "<td>".$data['ref_produit']."</td>";
//echo "<td><input type=\"text\" size = 10 name=\"quantite\" value=\"".$fetchquantite[0]."\" /></td>";
echo "<td><input type='text' size = 10 name='quantite' value= '".$data['quantite']."' /></td>";
echo "<td>".$data['total_produit']."</td>
<td>";
echo "<input type =submit value = senregistrer></td>";
echo "</tr>";
echo "</form>";
}
}
echo "</body><html>";
?> |
puis page avec (après) les modifications du panier
panieressai2.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
<?
error_reporting(E_ALL);
session_start();
echo "<html>
<title>Annulation</title>
<body bgcolor = #CCCCCC>
<p align = center><b><u><font size = +2>Annulation commande </p></u></font>
<center>";
if(!($base=mysql_connect("localhost","root","oye")))
{
echo "<br><B>probleme lors de la connexion à MySql</B><br>";
exit();
}
else
{
mysql_select_db("bd", $base);
//$prix = $_POST['prix'];
$quantite = $_POST['quantite'];
$ref = $_SESSION['ref_produit'];
echo $ref;
$reference = "SELECT prix_produit FROM produit WHERE ref_produit = '".$ref."'";
$querre = mysql_query($reference);
$fetref = mysql_fetch_array($querre);
$nouvotot = $quantite*$fetref[0];
$update = "UPDATE panier2 SET quantite = '".$quantite."', total_produit = '".$nouvotot."' WHERE id_cli = '1' AND ref_produit = '".$ref."'";
$fet = mysql_query($update);
$fetch = mysql_affected_rows();
$sel = "SELECT ref_produit, quantite, total_produit FROM panier2 WHERE id_cli = '1'";
$quer = mysql_query($sel);
echo "<table border ='1' cellpadding='1' cellspacing='0' bordercolor='black'>";
echo "<tr>";
echo "<td><center><b>Réference</center></b></td>";
//echo "<td><center><b>Prix unitaire</center></b></td>";
echo "<td><center><b>Quantite</center></b></td>";
echo "<td><center><b>Total produit</center></b></td>";
echo "<td><center><b>Modif</center></b></td>";
echo "<td><center><img src = corbeille.GIF></center></td>";
echo "</tr>";
while ($fet = mysql_fetch_array($quer))
{
echo "<tr>";
//echo "<input type='hidden' name= 'ref_produit' value='".$quer['ref_produit']."' />";
echo "<td>".$fet['ref_produit']."</td>";
//echo "<td><input type=\"text\" size = 10 name=\"quantite\" value=\"".$fetchquantite[0]."\" /></td>";
echo "<td> ".$fet['quantite']." </td>";
echo "<td>'".$fet['total_produit']."'</td>";
echo "</tr>";
echo "</form>";
}
}
echo "</body></html>";
?> |
si quelqu'un veut bien m'aider à comprendre...
merci d'avance !