Bonjour,

Après avoir fait et adapté le tuto panier.php, j'ai voulu envoyer mes données sur ma table $cmde, à partir d'une page de confirmation de commande.

J'ai bien le contenu du panier qui s'affiche dans cette page de confirmation, mais ne s'entre dans ma table que le dernier produit inscrit dans mon panier.

Bien que j'ai appris beaucoup au cours de ces derniers mois, je suis encore trop "novice" pour en comprendre la raison, et trouver la solution à mon problème dépasse mes maigres compétences.

Voici ce que j'ai fait :
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
//Avant ces lignes, j'ai récupéré et affiché les coordonnées de l'acheteur//
 
if (creationPanier())
{
$nbArticles=count($_SESSION['panier']['libelle']);
   for ($i=0 ;$i < $nbArticles ; $i++)
 
echo "<td>".htmlspecialchars($_SESSION['panier']['libelle'][$i])."</ td>";
echo "<td>".htmlspecialchars($_SESSION['panier']['fournisseur'][$i])."</ td>";
echo "<td>".htmlspecialchars($_SESSION['panier']['ref'][$i])."</ td>";
echo "<td><input type='text' size='3' name='QteArticle[]' value='".htmlspecialchars($_SESSION['panier']['qte'][$i])."'/></td>";
echo "<td>".sprintf("%01.2f",$_SESSION['panier']['price'][$i])."</td>";
echo "<td>".sprintf("%01.2f",$_SESSION['panier']['total'][$i] = $_SESSION['panier']['qte'][$i] * $_SESSION['panier']['price'][$i])."</td>";
echo "<td>".sprintf("%01.2f",$_SESSION['panier']['gain'][$i])."</td>";
echo "<td>".sprintf("%01.2f",$_SESSION['panier']['totalgain'][$i] = $_SESSION['panier']['qte'][$i] * $_SESSION['panier']['gain'][$i])."</td>";
 
$libelle = addslashes($_SESSION['panier']['libelle'][$i]);
$hid = addslashes($_SESSION['panier']['fournisseur'][$i]);
$ref = htmlspecialchars($_SESSION['panier']['ref'][$i]);
$qte = htmlspecialchars($_SESSION['panier']['qte'][$i]);
$price = sprintf("%01.2f",$_SESSION['panier']['price'][$i]);
   }
 
echo "Totaux (en euros) : </td>";
echo "<td>".sprintf("%01.2f",MontantGlobal());
  echo "</td>";
  echo "<td>".sprintf("%01.2f",MontantGain());
  echo "</td>";
  echo "</tr>";
  echo "</table>";
}
 
 
$now = date("d/m/Y");
 
$sql = "INSERT INTO sbbcmde VALUES ('','$ref', '$libelle', '$qte', '$price',  '$nom', '$adresse', '$cp', '$ville', '$tel', '$mobile', '$email', '$comments', '$hid', '$now')";
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
Merci par avance pour l'aide qui me sera apportée.