le 19/03/2005 à 16:47
pb de variable qui ne passe pas
oui, d'accord c'était une énorme bêtise, mais c'est comme ca qu'on apprend quand on est débutant.
Merci à tous pour vos conseils.
Merci à tous pour vos conseils.
<?php
$_SESSION ['total'] = $total ;
$total=0.00; // initialisation du total de la commande à 0
for ($i=0;$i<count($liste);$i++)
{//début du bloc for
[\code]
mais ce ne change rien.
Qu'est-ce que je fais de mal ?
<?php
session_start();
//init des variables
if(!isset($HTTP_GET_VARS['ajoutPanier'])) $ajoutPanier="";//init de nb si non déclaré
else $ajoutPanier=$HTTP_GET_VARS['ajoutPanier'];
if(!isset($HTTP_GET_VARS['modifPanier'])) $modifPanier="";//init de modifPanier si non déclaré
else $modifPanier=$HTTP_GET_VARS['modifPanier'];
if(!isset($HTTP_GET_VARS['suppPanier'])) $suppPanier="";//init de suppPanier si non déclaré
else $suppPanier=$HTTP_GET_VARS['suppPanier'];
if(!isset($HTTP_GET_VARS['enregistreCommande'])) $enregistreCommande="";//init de enregistreCommande si non déclaré
else $enregistreCommande=$HTTP_GET_VARS['enregistreCommande'];
if ((!isset($HTTP_SESSION_VARS['liste']))&&($ajoutPanier=="")) $liste[]=array("VIDE",1,0,0);//init de liste si VIDE
if (isset($HTTP_SESSION_VARS['liste'])) $liste=$HTTP_SESSION_VARS['liste'];//recup de la liste de la session
if (!isset($_SESSION['total']))$total=0;
else $total=$_SESSION['total'];
?>
...
<?php
$total=0.00; // initialisation du total de la commande à 0
for ($i=0;$i<count($liste);$i++)
{//début du bloc for
$query_rsPanier="select * from articles_rdt where reference ='".$liste[$i][1]."'";
$rsPanier=mysql_query($query_rsPanier, $ConnectionSiteRDT) or die(mysql_error());
$row_rsPanier=mysql_fetch_assoc($rsPanier);
/*définition et exécution de la requête SQL afin de récupérer les informations de l'article stocké dans la base(référence...)*/
?>
<tr bgcolor="#FFFF99">
<td width="99" height="20" bgcolor="#FFFF99" class="style17"><div align="left"><?php echo $row_rsPanier['code_rdt']; ?> </div></td>
<td width="204" height="20" bgcolor="#FFFF99" class="style17"><?php echo $row_rsPanier['reference'] ?></td>
<td width="96" height="20" bgcolor="#FFFF99" class="style11"><select name="nb<?php echo $i ?>" class="
liste[$i][2]==1) echo "SELECTED"; ?>>1</option></select>
<?php $total+=$row_rsPanier['PrixVenteTTC'] * $liste[$i][2];
}// fin du bloc for
?>
<strong>Total de votre commande <?php echo $total ?> € TTC </strong></span></td>
Page commande :
<?php
session_start();
//test si client déjà identifié
if (!isset($HTTP_SESSION_VARS['statut'])||($HTTP_SESSION_VARS['statut'] != "client"))
{ header("Location:login.php"); }
?>
<?php
//init des variables
if (!isset($_SESSION['total'])) $total=0;
else $total=$_SESSION['total'];
if (!isset($HTTP_GET_VARS['commandeID'])) $HTTP_GET_VARS['commandeID']=0;
if (!isset($HTTP_SESSION_VARS['statut'])) $statut="NON IDENTIFIE";
else $statut=$HTTP_SESSION_VARS['statut'];
if (!isset($HTTP_SESSION_VARS['action'])) $action="";
else $action=$HTTP_SESSION_VARS['action'];
if (!isset($HTTP_SESSION_VARS['liste'])) $liste[]=array("VIDE",1,0,0);//init de liste si VIDE
else $liste=$HTTP_SESSION_VARS['liste'];//recup de la liste de la session
if (!isset($HTTP_SESSION_VARS['clientID'])) $clientID=0;
else $clientID=$HTTP_SESSION_VARS['clientID'];
?>
<?php require_once('../Connections/ConnectionSiteRDT.php'); ?>
<?php
//enregistrement d'une nouvelle commande dans la table commandes
if (($action=="enregistre")&&($statut== "client"))
{
mysql_select_db($database_ConnectionSiteRDT, $ConnectionSiteRDT);
$insertCommande = "INSERT INTO commandes_rdt (date, clientID, total) VALUES (NOW(),'$clientID', '$total')";
$Result1 = mysql_query($insertCommande, $ConnectionSiteRDT) or die(mysql_error());
$commandeID=mysql_insert_id();//récupère l'identifiant client attibué ...
?>
Chargement en cours