voila mon probleme est que je ne trouve pas une solution a l'ajout de quantite d'un produit il me double le produit sinon le reste aucun probleme
voici deja ce que j'ai fais
catalogue.php
<?
$ajout="";
$msgajout="";
$id_produit="";
session_start();
//-----Les retours de variables-----//
if ( isset ($_GET['ajout']) == "retour")
{
$_SESSION['achats'][] = array ("id" => $_GET['id'], "qte" => $_GET['qte']);
$id_produit = $_GET['id'];
$msgajout = 'ajout pris en compte pour le produit a la reference';
}
//-----Données pour la connection a la bdd-----//
$hostname = "127.0.0.1";
$database = "CB";
$username = "root";
$password = "";
//-----Envoie de données de connection-----//
$connect = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db($database, $connect);
?>
<html>
<head>
<title>Test du nouveau caddie </title>
</head>
<body>
<? echo $msgajout; echo $id_produit;?>
<table>
<?
//-----Requette SQL-----//
$sql="SELECT * FROM `produits`";
$req=mysql_query($sql) or die("pas de table".mysql_error());
while($ligne=mysql_fetch_assoc($req))
{
$id_produit = $ligne['id_produits'];
$nom_produit = $ligne['nom_produit'];
$prix_produit = $ligne['prix_produit'];
?>
<tr>
<td>
<? echo $id_produit; ?>
</td>
<td>
<? echo $nom_produit; ?>
</td>
<td>
<? echo $prix_produit; ?>
</td>
<td>
<a href="catalogue.php?ajout=retour&id=<? echo $id_produit; ?>&qte=<? echo $qte='1';?>">Ajouter</a>
</td>
</tr>
<? } ?>
</table>
<a href="caddie.php">Voir le caddie </a>
</body>
</html>
caddie.php
<?
session_start();
//-----Ajout d'un produit-----//
if ( isset ($_GET['ajout']) == "retour")
{
$_SESSION['achats'][] = array ( "id" => $_GET['id'], "qte" => $_GET['qte']);
}
//-----Si les valeur du catalogue sont nuls-----//
if ( isset ($_SESSION['achats'])==""){
?> VOTRE CADDIE EST VIDE <?
exit();
}
//-----Recuparation des valeurs du catalogue-----//
for ($i=0; $i<count($_SESSION['achats']); $i++){
$id_produit = $_SESSION['achats'][$i]['id'];
$qte = $_SESSION['achats'][$i]['qte'];
//-----Données pour la connection a la bdd-----//
$hostname = "127.0.0.1";
$database = "CB";
$username = "root";
$password = "";
//-----Envoie de données de connection-----//
$connect = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db($database, $connect);
//-----Requete SQL-----//
$sql="SELECT * FROM `produits` WHERE `id_produits`= '$id_produit'";
$req=mysql_query($sql) or die("pas de table".mysql_error());
while($ligne=mysql_fetch_assoc($req))
{
$nom_produit = $ligne['nom_produit'];
$prix_produit = $ligne['prix_produit'];
?>
<html>
<head>
<title>
caddie
</title>
</head>
<body>
<table>
<tr>
<td>
<? echo $id_produit; ?>
</td>
<td>
<? echo $nom_produit; ?>
</td>
<td>
<? echo $prix_produit; ?>
</td>
<td>
<? echo $qte; ?>
</td>
<td>
<a href="caddie.php?ajout=retour&id=<? echo $id_produit; ?>&qte=<? echo $qte='1';?>">Ajouter</a>
</td>
</tr>
<? }
}
?>
</table>
</body>
</html>
Meric de bien vouloir m'aider car je trouve pas comment faire lol 