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
| if (creationPanier())
{
$nbArticles=count($_SESSION['panier']['Reference']);
if ($nbArticles <= 0)
echo "vide";
else
{
for ($i=0 ;$i < $nbArticles ; $i++)
{
$prod="SELECT * FROM Produit WHERE Reference=".$_SESSION['panier']['Reference'][$i]."";
$res_prod=mysql_query($prod)
or die (mysql_error());
$prix[$i] = round(($data['PrixUnitaire'] * ($data['QteMoyen']) * ($data['QteColis']) * ($_SESSION['panier']['QteCommandee'][$i])), 2);
$data = mysql_fetch_array($res_prod);
echo "<tr></tr>";
echo "<tr>";
echo "<td class='none'><font face='arial' size='2' color='#000066'>".htmlspecialchars($_SESSION['panier']['Reference'][$i])."</font></td><br/>";
echo "<td class='none' align='center'><font face='arial' size='2' color='#000066'>× ".$data['QteColis']."</font></td><br/>";
echo "<td class='none' align='center'><font face='arial' size='2' color='#000066'>".$data['QteMoyen']."</font></td><br/>";
echo "<td class='none' align='center'><font face='arial' size='2' color='#000066'>".$data['PrixUnitaire']."</font></td><br/>";
echo "<td class='none' align='center'><font face='arial' size='2' color='#000066'><input type=\"text\" size=\"2\" name=\"QteCommandee[]\" value=\"".htmlspecialchars($_SESSION['panier']['QteCommandee'][$i])."\"/></font></td><br/>";
echo "<td class='none' align='right'><strong><font face='arial' size='2' color='#000066'>$prix[$i] </font></strong></td><br/>";
echo "</tr>";
}
}
$ref=$_SESSION['panier']['Reference'];
$qte=$_SESSION['panier']['QteCommandee'];
if ($nbArticles <= 0)
exit ("Votre panier est vide. La commande ne peut être finalisée.");
else
{
for ($i=0 ;$i < $nbArticles ; $i++)
{
$requete ="INSERT INTO LigneCommande (LC_Id,Lc_IdCommande,LC_IdProduit,LC_Quantite,LC_MontantTTC,LC_MontantTVA) VALUES ('','test','".$ref[$i]."','".$qte[$i]."','".$prix."',19.6)";
$rq_insert = mysql_query($requete) or die ('Erreur '.$requete.' '.mysql_error());
}
}
}
?> |