<?php
include("secure.php");
include("pcdb.php");
$connexion = mysql_connect($hote, $utilisateur, $mdp);
$choix_base = mysql_select_db($data_base, $connexion)or die("Impossible d'ouvrir le fichier de comptes");
if(isset($_POST['Total']))
{
if(!empty($_POST['commande']))
{
$commande = $_POST['commande'];
$sql = "SELECT libelle, prix FROM prix, produit WHERE produit.idproduit = prix.idproduit";
$req = mysql_query($sql) or die (mysql_error());
while ($data = mysql_fetch_array($req))
{
$libelle = $data['libelle'];
foreach($commande as $choix)
{
echo '$data: '.$libelle;?><br /><?php
echo '$choix: '.$choix;?><br /><?php
echo $data['prix'];?><br /><br /><?php
if($libelle == $choix)
{
echo 'Somme Avant: '.$somme;
$prix = $data['prix'];
$somme = $somme + $prix;
echo $data['prix'];
echo 'Somme Après: '.$somme;
}
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>" xml:lang="fr" >
<head>
<title>LOGEM SOFTWARE ENGINEERING SA - Achat licence</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="LOGEM SOFTWARE ENGINEERING SA" />
<meta name="keywords" content="aide à la planification" />
</head>
<body>
<form action="test2.php" method="post">
<?php
$sql = "SELECT produit.idproduit, libelle, prix FROM prix, produit WHERE produit.idproduit = prix.idproduit";
$req = mysql_query($sql) or die(mysql_error());
while ($data = mysql_fetch_array($req))
{
?>
<div>
<span><input type="checkbox" name="commande[]" value=" <?php echo $data['libelle'];?>"><?php echo $data['libelle'];?></span>
<span>Prix:</span>
<span><?php echo $data['prix'];?></span>
</div>
<?php
}
mysql_close();
?>
<div><strong>Total: </strong><?php echo $somme; ?></div>
<div>
<span><input type="reset" name="Effacer" value="Effacer" /></span>
<span><input type="submit" name="Total" value="Total" /></span>
<span><input type="submit" name="Commander" value="Commander" /></span>
</div>
</form>
</body>
</html>