ok voici les pages
chez moi cela fonctionne parfaitement
le code est en brut j’ai pas trop eu le temps de tout optimiser (cookie1.php) ![]()
a toi de modifier le script en fonction de tes besoins
page articles.php
[cpp]
<?php
//On recupere l'Id de chaque produit
$queryID=mysql_query("select id, cat, ref, prix from galerie where Id='".$AfficheGalerie['id']."'");
$InfoProd=mysql_fetch_array($queryID);
?>
Quantité :
1
2
3
4
5
6
7
8
9
[/cpp]
page caddie1.php
[cpp]
page basket.php
[cpp]
<?php //on regarde si le panier est rempli if(count($_SESSION['achats'])==0){ echo '';}else{
for ($i=0; $i < count($_SESSION[‹ achats ›]); $i++){
$id_produit = $_SESSION[‹ achats ›][$i][‹ id ›];
$qte = $_SESSION[‹ achats ›][$i][‹ qte ›];
//affichag de ton caddie :
//requete sql pour recueperer le reference par rapport a l’id
$res=mysql_query(« select id, cat, ref, prix from galerie where id=' ».$id_produit.« ' »);
if($enr=mysql_fetch_array($res)){
$ref = $enr[« ref »];
$prix = $enr[« prix »];
}
//calcul du total
$total_art = $prix*$qte;
$total_panier += $total_art;
$total_art = number_format($total_art, 2, ‹ . ›, ’ ');
//affichage du resultat
?>
<tr>
<td width="100"><?php echo $ref; ?></td>
<td width="100"><?php include("include/select.php");?></td>
<td width="100"><?php echo $prix; ?></td>
<td width="150"><?php echo $total_art; ?></td>
<td width="50"><a href="include/caddie1.php?type=suppr&amp;id=<?php echo $id_produit;?>&amp;<?php echo strip_tags(SID);?>">suppr[/url]</td>
</tr>
<?php
}
$total_panier = number_format($total_panier, 2, '.', ' ');
?>
</tr>
<td colspan="5">&nbsp;</td>
</tr>
<tr>
<td colspan="3">Total panier :</td>
<td width="150"><?php echo $total_panier;?></td>
<td width="50">&nbsp;</td>
</tr>
<?php
}
?>
| Référence | quantité | prix unitaire | total | Suppr |
| | ||||
| Votre panier est vide | ||||
[/cpp]
page select.php
[cpp]
<?php //creation du selecteur //creation du select $liste = ''; $liste .=''; $liste .=''.$qte.''; for ($k = 1 ; $k < 10 ; $k++ ){ // dans ton cas je met 9 a la qte max $liste .= ''.$k.'';//j'appelle la page caddie pour le traitement de la session apres a toi d'adapter a ton code } $liste .=''; $liste .=''; echo $liste; ?>[/cpp]
edit : j’ai change la page caddie1.php car elle contenait une erreur de calcul pour la modif