Bonsoir à tous !

Je souhaite qu'au clic sur un bouton un produit se rajoute dans la table panier ou si le produit est déjà présent dans le panier que la quantité soit modifier et cela pour plusieurs produits à la fois.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<form action="<?php echo $editFormAction_doublon; ?>" onsubmit="return valider()" method="POST" name="achat_ensemble_doublon" id="achat_ensemble" >						
<input name="client" type="hidden" id="client" value="<?php echo $_SESSION['MM_Username']; ?>" />		  
 <input name="produit1" type="hidden" id="produit1" value="<?php echo $row_fiche_produit['id']; ?> " />
<input name="quantite1" type="hidden" id="quantite1" value="<?php echo $quantite1; ?> " />			  
 
							  <input name="produit2" type="hidden" id="produit2" value="<?php echo $parure_indispo2; ?> " />
<input name="quantite2" type="hidden" id="quantite2" value="<?php echo $quantite2; ?> " />
 
<?php  if($parure_indispo3 > 0){?> 							 
<input name="produit3" type="hidden" id="produit3" value="<?php echo $parure_indispo3; ?> " />
<input name="quantite3" type="hidden" id="quantite3" value="<?php echo $quantite3; ?>" /> 
<?php  }?>
 
 <label>
<input type="submit" name="acheter" id="acheter" value="Acheter l'ensemble complet" />
</label>
 <input type="hidden" name="MM_insert" value="achat_ensemble_doublon" />				
</form>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
$editFormAction_doublon = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction_doublon .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "achat_ensemble_doublon")) {
	if($row_doublonpanier1['quantite'] > 0){	
			 			$quantite1 = $row_doublonpanier['quantite'] + 1 ;
 
$updateSQL = sprintf("UPDATE panier SET produit=%s, quantite='$quantite1' WHERE client=%s",
                       GetSQLValueString($_POST['produit1'], "int"),
                       GetSQLValueString($_POST['client'], "text")); 
 mysql_select_db($database_xxx, $xxx);
  $Result_ens_doub1 = mysql_query($updateSQL, $xxx) or die(mysql_error()); 
}else{
 $insertSQL = sprintf("INSERT INTO panier (client, produit, quantite, taille) VALUES (%s, %s, %s, 'unique')",
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['produit1'], "int"),
                       GetSQLValueString($_POST['quantite1'], "int")); 		   
 
  mysql_select_db($database_xxx, $xxx);
  $Result_ens1 = mysql_query($insertSQL, $xxx) or die(mysql_error());
 
	}
 
if($row_doublonpanier2['quantite'] > 0){	
$quantite2 = $row_doublonpanier['quantite'] + 1 ;
 
$updateSQL = sprintf("UPDATE panier SET produit=%s, quantite='$quantite2' WHERE client=%s",
                     GetSQLValueString($_POST['produit2'], "int"),
                      GetSQLValueString($_POST['client'], "text")); 
mysql_select_db($database_xxx, $xxx);
 $Result_ens_doub2 = mysql_query($updateSQL, $xxx) or die(mysql_error()); 
	}else{
$insertSQL = sprintf("INSERT INTO panier (client, produit, quantite, taille) VALUES (%s, %s, %s, 'unique')",
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['produit2'], "int"),
                       GetSQLValueString($_POST['quantite2'], "int")); 		   
 
mysql_select_db($database_xxx, $xxx);
 $Result_ens2 = mysql_query($insertSQL, $xxx) or die(mysql_error());
 
}
 
if($parure_indispo3 > 0){
if($row_doublonpanier3['quantite'] > 0){	
$quantite3 = $row_doublonpanier['quantite'] + 1 ;
 
$updateSQL = sprintf("UPDATE panier SET produit=%s, quantite='$quantite3' WHERE client=%s",
                       GetSQLValueString($_POST['produit3'], "int"),
                       GetSQLValueString($_POST['client'], "text")); 
  mysql_select_db($database_xxx, $xxx);
 $Result_ens_doub3 = mysql_query($updateSQL, $xxx) or die(mysql_error()); 
}else{
 $insertSQL = sprintf("INSERT INTO panier (client, produit, quantite, taille) VALUES (%s, %s, %s, 'unique')",
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['produit3'], "int"),
                       GetSQLValueString($_POST['quantite3'], "int")); 		   
 
  mysql_select_db($database_xxx, $xxx);
  $Result_ens3 = mysql_query($insertSQL, $xxx) or die(mysql_error());
 
	}
}	
 
 header('Location: http://www.xxx.com/compte/panier.php');
J'imagine que ça ne marche pas car j'utilise la mauvaise syntaxe. J'ai cherché sur le web mais je n'ai pas réussi à trouver une situation équivalente...

Est-ce que quelqu'un pourrait me dire comment rédiger les INSERT et UPDATE successifs liés à des conditions ?