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 41 42 43 44 45 46 47 48 49 50 51 52
| <?php
session_start();
if( isset($_SESSION['panier'])){
$panier = $_SESSION['panier'];
$tot=0;// initialisation du total.
?>
<div align="center"><H2>Votre Caddie</H2></div>
<table border="1" align="center" bgcolor="cccccc" width="50%">
<tr bgcolor='white'>
<td width="">Produit</td>
<td width="">Quantité</td>
<td width="">Px Unité</td>
<td width="">Total </td>
<td width=""> </td>
</tr>
<form method="POST" action="ajout_panier.php">
<?php
$connexion = mysql_connect("localhost","root","")
or exit("Erreur 101") ;
mysql_select_db( "hbs" , $connexion)
or exit("Erreur 102") ;
foreach ($panier as $valeur=>$cde){
$sql="select * from ordinateur where id='$valeur'";
$req=mysql_query($sql)or exit ('Erreur SQL !'.$sql.'<br>'.mysql_error());
while( $data=mysql_fetch_array($req) ){
$nom=$data['nom'];//nom de la fleur
$prix=$data['prix'];// prix unitaire de la fleur
$pxligne=$prix*$cde; //prix pour la ligne de commande
$tot+=$pxligne;//valorisation du total général
?>
</form>
<form method="POST" action="">
<?php
echo"<tr><td>$nom</td><td><input type='text' name='qte' value=$cde />";
if (!empty($_POST['qte']))
{$qte=$_POST['qte'];
$id=$data['id'];
}
echo '<input type="submit" value="ok" />';
echo "</td><td>$prix</td><td align='right'>".number_format($pxligne, 2,'.',' ')."</td></tr>";
}
}
;
echo "<tr><td colspan='3' align='right'>Total Commandé...</td><td align='right'>".number_format($tot, 2,'.',' ')."</td></tr>";
mysql_close();
}
?>
</form> |
Partager