Récupérer une variable provenant d'une page...
Posté : 27 juil. 2005, 11:42
Bonjour à tous,
J'ai un ti problème, je suis en train de faire un site web d'e-commerce et sur la page du produit, j'ai mis un menu déroulant avec, à l'intérieur, les couleurs de ce produit (couleurs contenues dans une table).
Sur la page du produit, j'ai le choix entre plusieurs couleurs.
J'en sélectionne une, puis j'appuie sur "ajouter au panier".
Là, j'arrive sur la page panier et je vois le produit sélectionné avec une couleur totalement différente de celle que j'ai choisie (en l'occurence, la couleur avec l'ID n°1 dans la table).
Je vous mets un morceau du code de la page produit :
edit mere-teresa : Préfère PHP à Code, ça colore la syntaxe, bien plus agréable pour relire les tartines de code PHP/HTML mélangés. Merci.
J'ai un ti problème, je suis en train de faire un site web d'e-commerce et sur la page du produit, j'ai mis un menu déroulant avec, à l'intérieur, les couleurs de ce produit (couleurs contenues dans une table).
Sur la page du produit, j'ai le choix entre plusieurs couleurs.
J'en sélectionne une, puis j'appuie sur "ajouter au panier".
Là, j'arrive sur la page panier et je vois le produit sélectionné avec une couleur totalement différente de celle que j'ai choisie (en l'occurence, la couleur avec l'ID n°1 dans la table).
Je vous mets un morceau du code de la page produit :
<select name="select">
<?php
do {
?>
<option value="<?php echo $row_fiche['coul']?>"><?php echo $row_fiche['coul']?></option>
<?php
} while ($row_fiche = mysql_fetch_assoc($fiche));
$rows = mysql_num_rows($fiche);
if($rows > 0) {
mysql_data_seek($fiche, 0);
$row_fiche = mysql_fetch_assoc($fiche);
}
?>
</select>
</form>
Et le code de la page panier :
<?php require_once('Connections/connexion.php'); ?>
<?php
mysql_select_db($database_connexion, $connexion);
?>
<?php
session_start();
//init des vraiables
if (!isset($_SESSION['total'])) $_SESSION['total']=0;
if(!isset($_GET['ajout'])) $ajout="";
else $ajout=$_GET['ajout'];
if(!isset($_GET['modif'])) $modif="";
else $modif=$_GET['modif'];
if(!isset($_GET['suppr'])) $suppr="";
else $suppr=$_GET['suppr'];
if(!isset($_GET['save'])) $save="";
else $save=$_GET['save'];
if (isset($_SESSION['liste'])) $liste=$_SESSION['liste'];
//fin init
?>
<?php
//ajout
if ($ajout=="AJOUTER")
{
$ref=$_GET['ref'];
$nb=1;
$coul=$_GET['coul'];
$prix=$_GET['prix'];
$liste[]=array($ref,$nb,$coul,$prix,$prix);
$_SESSION['liste']=$liste;
}
//modif
if ($modif=="ACTUALISER")
{
for ($i=0;$i<count($liste);$i++)
{
$nbi='nb'.$i;
$liste[$i][1]=$_GET["$nbi"];
$liste[$i][5]=$liste[$i][1]*$liste[$i][4];
}
$_SESSION['liste']=$liste;
}
//suppr
if ($suppr=="SUPPRIMER")
{
for ($i=0;$i<count($liste);$i++)
{
if ($reference==$i)
array_splice($liste,$i,1);
}
$_SESSION['liste']=$liste;
}
//save
if ($save=="COMMANDER")
{
if(!isset($_GET['action']))
$_SESSION['action']="ENREGISTRER";
header("localisation : commande.php");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Ludion-Tables de massage</title>
<style type="text/css">
<!--
.Style7 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; font-weight: bold; }
-->
</style>
</head>
<body>
<table width="1026" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="10" colspan="4" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1026" height="10"></td>
</tr>
</table></td>
</tr>
<tr>
<td width="6" rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="10" height="581"> </td>
</tr>
</table></td>
<td height="110" colspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1020" height="110" valign="top"><a href="index.php"><img src="images/logo.gif" width="1020" height="110" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td width="194" height="200" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="194" height="50" valign="top"><a href="tables.php"><img src="images/pic/bouton1.gif" width="194" height="50" border="0"></a></td>
</tr>
<tr>
<td height="50" valign="top"><img src="images/pic/bouton2.gif" width="194" height="50"></td>
</tr>
<tr>
<td height="50" valign="top"><img src="images/pic/bouton3.gif" width="194" height="50"></td>
</tr>
<tr>
<td height="50" valign="top"><img src="images/pic/bouton4.gif" width="194" height="50"></td>
</tr>
</table></td>
<td width="15"> </td>
<td width="811" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="811" height="16" valign="top" class="Style7"> <a href="tables.php">< Poursuivez vos achats </a></td>
</tr>
<tr>
<td height="13"></td>
</tr>
<tr>
<td height="23" valign="top"><div align="center" class="Style7"><?php echo('Votre panier') ?> </div> <div align="center"></div></td>
</tr>
<tr>
<td height="164" valign="top"><form action="panier.php" method="get">
<table width="650" border="0" align="center" bordercolor="#FFFFFF">
<tr>
<td>
<table width="650" border="0" align="center">
<tr bgcolor="#FFFFFF">
<td width="100"><div align="center"><strong><?php echo('Référence'); ?></strong></div></td>
<td width="100"><div align="center"><strong><?php echo('Couleur'); ?></strong></div></td>
<td width="100"><div align="center"><strong><?php echo('Prix'); ?></strong></div></td>
<td width="100"><div align="center"><strong><?php echo('Suppr'); ?></strong></div></td>
</tr>
<?php
$total=0.00;
for ($i=0;$i<count($liste);$i++)
{
$query_panier = "SELECT liste_tables.idref, reference.`ref`, liste_tables.description, liste_tables.hauteur, liste_tables.image, liste_tables.prix, liste_tables.idcoul_gam, coul_gam.idcoul, couleur.coul FROM liste_tables, reference, coul_gam, couleur WHERE couleur.idcoul = coul_gam.idcoul AND coul_gam.idcoul_gam = liste_tables.idcoul_gam AND liste_tables.idref = reference.idref AND reference.`ref`= '".$liste[$i][0]."'";
$panier=mysql_query($query_panier, $connexion);
$row_panier=mysql_fetch_assoc($panier);
?>
<tr>
<td><div align="center" class="Style7"><?php echo $row_panier['ref'] ?></div></td>
<td><div align="center" class="Style7"><?php echo $row_panier['coul'] ?></div></td>
<td><div align="center"><span class="Style7"><?php echo $row_panier['prix']; ?></span> <span class="Style7"><strong>€ T.T.C</strong></span> </div></td>
<td><div align="center"><a href="panier.php?reference=<?php echo $row_panier['ref']?>&suppr=SUPPRIMER"><img src="images/ok%20copie.jpg" width="57" height="26" border="0"></a></div></td>
</tr>
<?php
$total+=$row_panier['prix'] * $liste[$i][1];
}
$_SESSION['total']=$total;
?>
<tr>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center" class="Style7"><strong>Total : <?php echo $total ?> € T.T.C </strong></div></td></tr>
</table>
</td>
</tr>
</table>
<br>
<p align="center">
<input name="save" type="Submit" value="COMMANDER">
</p>
</form></td>
</tr>
<tr>
<td height="255"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="271"></td>
<td></td>
</tr>
</table>
</body>
</html>
Bon, je précise aussi que lorsque j'appuie sur "commander", rien ne se passe...mais c'est pas urgent.edit mere-teresa : Préfère PHP à Code, ça colore la syntaxe, bien plus agréable pour relire les tartines de code PHP/HTML mélangés. Merci.