Salut je suis à la recherche de conseils svp,
Voila je suis entrain de crée un petit panier e-commerce pour lister les articles et en choisir un sa c'est bon
af_article2.php = liste de tout les articles
s_article2.php = un article selectionne dans la page d'avant
caddie2.php = au cadie
Liens de s_article2.php qui envoi vers le cadie
echo '<a href="caddie2.php?idprd='.$id.'&qte=1">Commander</a>';
Quand je l'ajoute au caddie il s'affiche mais dès que je resort de la page il disparait pourtant la session est je pense bien ouverte.
J'ai reflechi au probleme que j'ai sur comment differencier les produits et à les affiches en leur donnant une id dans la session
Parce que la à chaque fois que je rajoute un produit il ecrase la session je pense.
Et pour les affiches je pense qu'il faut faire un foreach mais j'ai essayer pleins de methodes sa marche pas je vois pas quoi recupere
Si quelq'un peut m'aider pour me dire comment faire c'est deux manip est le probleme dans mon code du caddie merci bcp
Merci @++
Voici la page caddie2.php
<?php
session_start();
require "../include/config.php";
//Suppression
if(isset($_GET['suppr'])){
$idprd=$_GET['suppr'];
if(empty($_SESSION["panier"]["contenu"])){
unset($_SESSION["panier"]["contenu"]);
$redir = "<meta http-equiv=\"refresh\" content=\"1;url=caddie2.php\"/>";
} }
//Ajout
if(isset($_GET['idprd']) && isset($_GET['qte'])){
$idprd=$_GET['idprd'];
$qte=$_GET['qte'];
if(empty($_SESSION["panier"]["contenu"])){
$_SESSION["panier"]["contenu"] = array();
$_SESSION["panier"]["contenu"]["id_produit"] = $idprd;
$_SESSION["panier"]["contenu"]["quantite_produit"] = $qte;
}
else {
$_SESSION["panier"]["contenu"] = array();
$_SESSION["panier"]["contenu"]["id_produit"] = $idprd;
$_SESSION["panier"]["contenu"]["quantite_produit"] = $qte;
} }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
<html xmlns="
[ Lien ]" xml:lang="fr">
<head>
<?php if (isset($redir)) print($redir); ?>
<title></title>
<link rel="stylesheet" type="text/css" href="../css/site.css" />
<style type="text/css">
<!--
body {
background-color: #666666;
}
-->
</style>
</head>
<body>
<br /><p align="center" class="titre">Votre Caddie...</p>
<?php
if (isset($_SESSION["panier"]["contenu"])){
echo '<p align="center" class="aff2"><a href="af_article2.php">Retour à la Boutique</a>';
echo '<table border="1" align="center" width="650" cellpadding="0" cellspacing="0"><tr class="menu">';
echo '<td width="200" align="center">Produit</td>';
echo '<td width="100" align="center">Quantité</td>';
echo '<td width="100" align="center">Px Unité</td>';
echo '<td width="100" align="center">Poids Unité</td>';
echo '<td width="100" align="center">Total </td>';
echo '<td width="50" align="center">DEL</td></tr>';
$tot=0;// initialisation du total.
$sql="SELECT * FROM article WHERE id='".$_GET['idprd']."'";
$req = mysql_query($sql);
while ($data=mysql_fetch_array($req) ){
$aze = $_SESSION["panier"]["contenu"]["id_produit"];//Resultat session id
$cde = $_SESSION["panier"]["contenu"]["quantite_produit"];//Resultat session quantite
$idarticle=$data['id'];//id de l'article
$nom=$data['nom'];//nom de l'article
$prix=$data['prix'];// prix unitaire
$quantitemax=$data['quantite'];//quantite max
$pxligne=$prix*$cde; //prix pour la ligne de commande
$tot+=$pxligne;//valorisation du total général
$poids=$data['poids'];// poids unitaire
$poidsligne=$poids*$cde; //poids pour la ligne de commande
$totpoids+=$poidsligne;//valorisation du total poids général
$tva=$data['tva'];// tva
$totalttc = $tot + ($tva / 100 + 1);
echo '<tr><td align="center" class="aff">'.$aze.' - '.$nom.'</td>';
echo '<td align="center" class="aff">'.$cde.'</td>';
echo '<td align="center" class="aff">'.$prix.'</td>';
echo '<td align="center" class="aff">'.$poids.'</td>';
echo '<td align="right" class="bug">'.number_format($pxligne, 2,'.',' ').'</td>';
echo '<td align="center"class="bug"><a href="caddie2.php?suppr='.$idarticle.'">';
echo '<img src="../img/panier_del.gif" width="13" height="13" border="0"/></a></td></tr>';
}//while
}//if (isset($_SESSION["panier"]["proprietaire"]["log"]))
echo '<tr><td colspan="4" align="right" class="menu">Total Commandé...</td><td align="right" class="bug">'.number_format($tot, 2,'.',' ').'</td></tr>';
echo '<tr><td colspan="4" align="right" class="menu">Tva...</td><td align="right" class="bug">'.$tva.'</td></tr>';
echo '<tr><td colspan="4" align="right" class="menu">Poids Total...</td><td align="right" class="bug">'.number_format($totpoids, 2,'.',' ').'</td></tr>';
echo '<tr><td colspan="4" align="right" class="menu">Total TTC...</td><td align="right" class="bug">'.number_format($totalttc, 2,'.',' ').'</td></tr>';
echo '</table>';
echo '<a href="s_article2.php?prod='.$idarticle.'">Retour à l\'article</a></p>';
?>
</body></html>
Voici la table d'exemple
CREATE TABLE `article` (
`id` int(11) NOT NULL auto_increment,
`nom` varchar(100) default NULL,
`prix` decimal(5,2) default '0.00',
`quantite` int(11) default '0',
`poids` decimal(5,2) default '0.00',
`tva` decimal(5,2) default '0.00',
`detailsfr` text,
`detailsen` text,
`image` varchar(100) default NULL,
`reference` char(30) default NULL,
`dateajout` datetime default NULL,
`datefini` datetime default NULL,
`image2` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `article` VALUES ('1','test','10.20','5','0.60','19.60','detailsfr','detailsen','','','','','');
INSERT INTO `article` VALUES ('2','test2','5.50','5','5.50','19.60','french','english','','','','','');