<form name="commande" action="commande.php" method="get" enctype="multipart/form-data">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr><td>
<table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="130"> </td>
<td width="80" align="center">Prix</td>
<td width="70" align="center">Quantité</td>
</tr>
<?php while ($row = mysql_fetch_array($result)) { ?>
<tr>
<?php echo ('<input type="hidden" name="id_article" value="'.$row['id'].'">'); ?>
<?php echo ('<input type="hidden" name="nom" value="'.$row['nom'].'">'); ?>
<?php echo ('<input type="hidden" name="prix" value="'.$row['prix'].'">'); ?>
<td width="130" height="30"><span class="choix"><?php echo $row['nom'] ?></span></td>
<td align="right"><?php echo $row['prix']; ?> €</td>
<td align="center"><input type="text" name="quantite" value="" size="2" maxlength="2" align=""></td>
</tr>
<?php } ?>
</table>
</td>
<td>
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr><td><INPUT type="submit" value="Ajouter à la commande" name="ajout"></td></tr>
</table>
</td></tr>
</table>
</form>
Cette page compte 3 colonnes (+1 cachée) nom, prix, quantite (id_article).La liste de mes produits s'affiche bien mais mon problème est l'ajout au panier.
L'utilisateur entre la quantité voulue de plusieurs produits et valide le formulaire.
Mais... il ne tient compte que du dernier produit. Comment puis-je récupérer un produit à la fois dans ce GET. Une autre boucle?
Code : Tout sélectionner
commande.php?id_article=1&nom=coca&prix=1.00&quantite=2&id_article=2&nom=coca+light&prix=1.00&quantite=2&id_article=3&nom=coca+zero&prix=1.00&quantite=3&ajout=Ajouter+%E0+la+commande$select['id'] = $_GET['id_article'];
$select['nom'] = $_GET['nom'];
$select['quantite'] = $_GET['quantite'];
$select['prix'] = $_GET['prix'];
if(!verif_panier($select['id'])) {
array_push($_SESSION['panier']['id'],$select['id']);
array_push($_SESSION['panier']['nom'],$select['pain']);
array_push($_SESSION['panier']['quantite'],$select['quantite']);
array_push($_SESSION['panier']['prix'],$select['prix']);
}
D'avance MERCI.