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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| <html>
<head>
<title>Librairie</title>
</head>
<body>
<form method="post" action="">
<fieldset>
<legend>Synthese</legend>
<p>Total des chiffres d'affaires par :</p>
<select name="CA">
<option></option>
<option value="trim">Trimestre</option>
<option value="cat">Categorie</option>
</select>
<br/><br>
<input type="submit" name="Afficher" value="Afficher" />
</fieldset>
</form>
<?php
if (isset($_POST['Afficher'])) {
$ca=$_POST['CA'];
$connexion=mysql_connect ('localhost','root','') or die ('Connexion impossible !'.mysql_error());
$ok=mysql_select_db('librairie',$connexion) or die ('Selection impossible !'.mysql_error());
if($ca==''){
echo 'Selectionnez un critere !';
}
else if (!empty ($ca)) {
if($ca=='cat'){
$sql="SELECT categorie,SUM(trim1),SUM(trim2),SUM(trim3),SUM(trim4) FROM ca";
$req=mysql_query($sql);
$ligne=mysql_fetch_row($req);
echo '<table border="1">';
echo '<tr><th>Categorie</th><th>Chiffre d\'affaire</th></tr>';
while($ligne=mysql_fetch_row($req)){
echo '<tr><td>'.$ligne[0].'</td><td>'.$ligne[1].'</td><td>'.$ligne[3].'</td><td>'.$ligne[4].'</td><td>'.$ligne[5].'</td><td>'.$ligne[6].'</td><td>'.$ligne[7].'</td><td>'.$ligne[8].'</td><td>'.$ligne[9].'</td><td>'.$ligne[10].'</td><td>'.$ligne[11].'</td><td>'.$ligne[12].'</td></tr>';
}
}
echo '</table>';
}
elseif($ca=='trim'){
$sql="SELECT SUM(trim1),SUM(trim2),SUM(trim3),SUM(trim4) FROM ca GROUP BY categorie";
$req = mysql_query($sql);
$ligne= mysql_fetch_row($req);
echo '<table border="1">';
print_r '<tr><th>Trimestre</th><th>Chiffre d\'affaire</th></tr>';
while($liste=mysql_fetch_row($req)){
echo '<tr><td>'.$ligne[0].'</td><td>'.$ligne[1].'</td><td>'.$ligne[2].'</td><td>'.$ligne[3].'</td><td>';
}
echo '</table>';
}
}
//clôture finale de la db
mysql_close ();
?>
</body>
</html> |
Partager