oulala je me tire les cheveux depuis des heures et rien de concluant
j'ai simplifié ce code mais rien à faire, ça me rajoute une ligne avec la modification (dans mon formulaire) au lieu d'afficher la modification dans le champs "quantite". j'ai donc une 2eme ligne qui s'affiche.
[code]
<?
session_start();
$sessionidclient = $_SESSION['id_client'];
echo $_SESSION['id_client']."Identifiant client";
echo "<br><br>";
$article = $_POST['article'];
echo $article;
echo "<br>";
$quantite = $_POST['quantite'];
//connexion à la BDD
$req1 = "SELECT ref_produit, prix_produit FROM produit WHERE designation_produit = '".$article."'";
$query1 = mysql_query($req1) or die(mysql_error());
$fetch1 = mysql_fetch_array($query1);
$total = $fetch1['prix_produit']*$quantite;
$inser = "INSERT INTO panier (id_cli, ref_produit, quantite, total) VALUES ( '".$_SESSION['id_client']."','".$fetch1['ref_produit']."', '".$quantite."', '".$total."')";
$inquer = mysql_query($inser) or die(mysql_error());
$affected = mysql_affected_rows();
$reqtot = "SELECT sum(total) FROM panier WHERE id_cli = '".$_SESSION['id_client']."' ";
$querytot = mysql_query($reqtot) or die(mysql_error());
$fetchtot = mysql_fetch_array($querytot);
if(isset($_POST['sub_form']))
{
if ($_POST['sub_form'] == 'modifier')
{
$modif = "UPDATE panier SET quantite = '".$_POST['quantite']."', total = '".$fetch1['prix_produit'] * $_POST['quantite']."'
WHERE ref_produit = '".$fetch1['ref_produit']."' AND id_cli = '".$_SESSION['id_client']."'";
$res = mysql_query($modif) or die (mysql_error());
}
}
$select = "SELECT ref_produit, quantite, total FROM panier WHERE id_cli = '".$_SESSION['id_client']."' ";
$quersel = mysql_query($select) or die(mysql_error());
echo "<table border= 2>
<tr>
<td><center><b>Reference</td></center></b>
<td><center><b>Quantite</td></center></b>
<td><center><b>Total produit</td></center></b>
<td>Modifier</td></tr>";
while($fetchsel = mysql_fetch_assoc($quersel))
{
echo "<form method= 'post' action='{$_SERVER['PHP_SELF']}'>";
echo "<tr>
<td>".$fetchsel['ref_produit']."</td>
<td><input type = text name = quantite value = ".$fetchsel['quantite']." ></td>
<td>".$fetchsel['total']."</td>
<td><input type = submit name = 'sub_form' value = 'modifier'></td>
</tr>
</form>";
}
echo "</table>
";
}
?>
[/code]