Récuperer les informations du panier pour envoie à la Base de Données
Bonjour, je viens de créer un panier mais je ne sais pas comment transferer les informations dans la base..
Voici mon code affichage_panier.php:
Code:
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 37 38 39 40
| <?php
foreach ($_SESSION['caddie'] as $idProduit => $quantite)
{
$rq="SELECT * FROM magazine WHERE ref_produit='".$idProduit."'";
$res=mysql_query($rq)or die("erreur dans la requete" );
$ligne=mysql_fetch_array($res);
$nom=$ligne['titre'];
$prix_unitaire=$ligne['prix'];
$prix_total=$prix_unitaire*$quantite;
$caddie += $prix_total;
$ref = $ligne["ref_produit"];
echo'<tbody>
<tr>
<td>'.$nom.'</td>
<td>'.$prix_unitaire.'</td>
<td>'.$quantite.'</td><td>'.$prix_total.'</td>
<td><a href="retrait_caddie.php?retrait='.$ref.'"><img src="http://nsa21.casimages.com/img/2012/03/24/120324125149189150.png" /></a></td>
</tr>
</tbody>';
}
echo' <tfoot>
<tr>
<td colspan="5">TOTAL COMMANDE = '.$caddie.' </td>
</tr>
<tr>
<td colspan="1"><a href="www.google.fr"><img src="http://nsa22.casimages.com/img/2012/03/24/120324125951900829.png" /></a> </td>
<td colspan="5"><a href="www.google.fr"><img src="http://nsa21.casimages.com/img/2012/03/24/120324010245531262.png" /></a> </td>
</tr>
</tfoot>
</table>'; |
et mon ajout_caddie.php:
Code:
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
| <?php
session_start(); //demarrage de la session
header("Location: affichage_panier3.php\n\n");
if(isset($_GET['ajout']))
{
$ref = $_GET['ajout']; //reference du produit choisi
if(!isset($_SESSION['caddie'])) //si le caddie n'a pas encore ete cree
{
$_SESSION['caddie'] = array(); //creation de la variable de session
}
if(isset($_SESSION['caddie'][$ref ])) //si ce produit a deja ete choisi
{
$_SESSION['caddie'][$ref ]++; //ajoute 1 a la quantite
}
else
{
$_SESSION['caddie'][$ref ] = 1; //si 1er ajout, met la quantit a 1
}
}
?> |
Merci