bonjour,
J'ai réalisé un site e-commerce avec Dreamweaver MX 2004 et PHP/MySQL suivant le livre de François Houste, collection Campus Press.
J'ai un petit problème à la fin du livre ( page 228 ). La page traitement_commande.php de validation ne se fait pas.

Ci-dessous le tableau dans Data-base



Voici le film de démonstration pour vous montrer mon problème :

http://hoangestelle.free.fr/site_com...traitement.htm

Le problème est que les articles commandés dans la page traitement_commande.php ne sont pas enregistrés dans shop_ligne_commande et ces articles ne sont pas supprimés dans shop_panier.

Voici les codes PHP de la page traitement_commande.php

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
<?php

if (isset($_SESSION['MM_Username'])) {
mysql_select_db($database_Maboutique, $Maboutique);
$query_commande = sprintf("SELECT id_commande FROM shop_commande WHERE client = '".$_SESSION['MM_Username']."' ORDER BY id_commande DESC"); 
$commande = mysql_query($query_commande, $Maboutique) or die(mysql_error());
$row_commande = mysql_fetch_assoc($commande);
$totalRows_commande = mysql_num_rows($commande);


mysql_select_db($database_Maboutique, $Maboutique);
$query_panier = sprintf("SELECT shop_panier.*, shop_produit.prix_ttc,
shop_produit.prix_ttc*shop_panier.quantite AS total_ttc FROM shop_panier INNER JOIN shop_produit ON shop_produit.id_article = shop_panier.ref_produit WHERE client = '".$_SESSION['MM_Username']."'");
$panier = mysql_query($query_panier, $Maboutique) or die(mysql_error());
$totalRows_panier = mysql_num_rows($panier);
$compteur = 0;

while ($row_panier = mysql_fetch_assoc($panier) and $compteur < $totalRows_panier)
{
$query_ligne_commande = sprintf("INSERT INTO shop_ligne_commande (ref_commande, ref_produit, prix_ttc, quantite, total_ttc) VALUES (%s, %s, %s, %s, %s)", 
GetSQLValueString($row_commande['id_commande'], "int"),
GetSQLValueString($row_panier['ref_produit'], "int"),
GetSQLValueString($row_panier['prix_ttc'], "double"),
GetSQLValueString($row_panier['quantite'], "int"),
GetSQLValueString($row_panier['total_ttc'], "double"));
mysql_select_db($database_Maboutique, $Maboutique);
$Result1 = mysql_query($query_ligne_commande, $Maboutique) or die(mysql_error());
$query_suppr_panier = sprintf("DELETE FROM shop_panier WHERE id_panier=%s",
GetSQLValueString($row_panier['id_panier'], "int"));
mysql_select_db($database_Maboutique, $Maboutique);
$Result1 = mysql_query($query_suppr_panier, $Maboutique) or die(mysql_error());

$compteur = $compteur+1;
  }
}                                                                                       
?>
Merci.