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 85 86 87 88 89 90 91 92 93
| <?php
// connexion bdd
try
{
$bdd = mysqli_connect('localhost', 'root', '06193475L', 'base-pacetel');
$bdd->set_charset("utf8");
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
if(isset($_POST['liste1'])){
//si la liste a été "postée" c ad choix fait
$liste1=$_POST['liste1'];
}else{
$liste1=-1;
}
?>
Sélectionnez un client :
<form name="form1" method="post" action="index.php">
<select name="liste1" onchange=" form1.submit();">
<option value=-1>-- Choisissez -- </option>
<option>Lumelec</option><!--* il faut cette ligne pour avoir obliagtoirement un changement -->
<option>client2</option>
<option>client3</option>
<option>client4</option>
<option>client5</option>
<?php
$requete = "SELECT nomclient FROM facture2015";
$execution_requete = mysql_query($requete);
while($total = mysql_fetch_array($execution_requete))
//Liste déroulante client
{
echo "<option value=\"".$total["nomclient"]."\"";
if($liste1==$total['nomclient']) { echo "selected"; }//ça c'est pour garder la selection lors du réaffichage
echo ">".$total['nomclient']."</option>\n";
}
$requete1 = "SELECT mois FROM facture2015";
$execution_requete1 = mysql_query($requete1);
while($total1 = mysql_fetch_array($execution_requete1))
//Liste déroulante client
{
echo "<option value=\"".$total1["Type"]."\"";
if($liste2==$total1['Type']) { echo "selected"; }//ça c'est pour garder la selection lors du réaffichage
echo ">".$total1['Type']."</option>\n";
}
?>
</select>
</form>
<?php
if($liste1 != -1){ //si on a fait un choix
//on refait une requette avec une condition
$escaped_liste1 = mysql_real_escape_string($liste1);
$req = "SELECT DISTINCT nomclient,Numero,Destination,value,valeur,StartValue,coutCDR,Type,mois FROM `facture2015` WHERE `nomclient` ='".$escaped_liste1."'";
$res = mysqli_query($bdd,$req);
// on va scanner tous les tuples un par un
echo " "."<th>entreprise</th>"."                      "."<th>Numero</th>"."                           "."<th>Destination</th>"."                    "."<th>value</th>"."                            "."<th>valeur</th>"."                               "."<th>StartValue</th>"."           "."<th>coutCDR</th>"."           "."<th>Type</th>"."       "."<th>mois</th>" ;
echo "<table>";
while ($data = mysqli_fetch_array($res)) {
// on affiche les résultats
echo "<tr><td>".$data['nomclient']."</td><td>".$data['Numero']."</td><td>".$data['Destination']."</td><td>".$data['value']."</td><td>".$data['valeur']."</td><td>".$data['StartValue']."</td><td>".$data['coutCDR']."</td><td>".$data['Type']."</td><td>".$data['mois']."</td></tr>";
}
echo "</table>";
*//or die('erreur affichage');
}
?>
</form>
</div>
</body>
<html> |
Partager