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
|
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<title>La commande</title>
</head>
<body>
<?php
include("config.inc.php"); // cfg.php garde les informations concernant le serveur et la base
error_reporting(0);
?>
<?php
echo "<table width='480' border='1' bordercolor='#000000' cellspacing='0'><tr><td>Nom</td><td>Prix</td><td></td></tr>";
$reqtxt="SELECT * FROM article WHERE Quantité>0";
$restxt=mysql_query($reqtxt);
while($donnees = mysql_fetch_array($restxt))
{
$req_nom=$donnees[0];
$req_qte=$donnees[1];
$req_prix=$donnees[2];
echo "<tr><td>".$req_nom."</td><td>".$req_prix." ".$req_qte."</td><td>";
echo "<form method='post' action='commande.php'>";
echo "<input type='hidden' name='".$req_nom."' value='".$req_nom."'</input>";
echo "<input type='hidden' name='".$req_qte."' value='".$req_qte."'</input>";
echo "<input type='hidden' name='".$req_prix."' value='".$req_prix."'</input>";
echo "<input type=submit value='Ajouter au panier'>";
echo "</form></td></tr>";
}
echo "</table>";
$_SESSION[$req_nom]=$_POST[$req_nom];
$_SESSION[$req_qte]=$_POST[$req_qte];
$_SESSION[$req_prix]=$_POST[$req_prix];
if (isset($_SESSION[$req_nom])&&isset($_SESSION[$req_qte])&&isset($_SESSION[$req_prix])) {
echo "Panier :<br>";
echo "<table border=1><tr><th></th><th>Quantité</th><th>Prix</th></tr>";
echo "<tr><td>".$_SESSION[$req_nom]."</td><td>3</td><td></td></tr>";
echo "</table>";
} else {
echo "Votre panier est vide";
}
?> |
Partager