Bonjour , j'essaye d'afficher les données dans ma base de donnée selon le choix dans la liste déroulante. En effet j'ai un champ zone et j'ai trois zones que je met dans une liste déroulante. je veux quand je sélectionne dans la liste la zone 1 m'affiche les données attachées à la zone 1 et zone 2 données attachées à la zone 2. J'ai fait un programme mais ça change rien quand je sélectionne différentes zones dans la liste j'ai toujours le même affichage
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="../Parc_Transformateur.css" /> <title> </title> </head> <body> <div> <?php include_once("menu_admin.php"); include_once("../db_connection.php"); ?> <form name ="form2" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <fieldset> <legend class="titre_1">Afficher les transformateurs affichés dans le Parc? </legend> </select></p> <p class="ligne_form_1">Choix de la zone : <select name="choix_zone" id="choix_zone";"> <option value="zone1">Zone1 </option> <option value="zone2">Zone2 </option> <option value="zone3">Zone3 </option> </select></p> <?php //requête SQL: if($choix_zone='zone1') { $sql = "SELECT * FROM transformateur where zone='zone1'" ; //exécution de la requête: $requete = mysql_query( $sql) ; echo( "<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\">\n" ); echo( " <tr> <td colspan=\"1\" rowspan=\"2\"align=\"center\">Identifiant</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Marque</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Date de fabrication</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Type</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Puissance</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Quantite d'huile</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">PCB</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Valeur</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Poste de stockage </td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Modifier </td> </tr> <tr> </tr>" ); //affichage des données: while( $result = mysql_fetch_array( $requete ) ) { echo( "<tr>\n" ); echo( "<td><div align=\"center\">".$result['identifiant']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['marque']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['date_fabrication']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['type']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['puissance']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['qtite_huile']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['pcb']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['valeur']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['zone']."</div> </td>\n" ); echo("<td><div align=\"center\"> <a href=\"affiche1.php?idtransfo='".$result['identifiant']."'\">Modifier</a></div></td>\n") ; echo( "</tr>\n" ); } echo( "</table><br>\n" ); } if($choix_zone='zone2') { $sql = "SELECT * FROM transformateur where zone='zone2'" ; //exécution de la requête: $requete = mysql_query( $sql) ; echo( "<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\">\n" ); echo( " <tr> <td colspan=\"1\" rowspan=\"2\"align=\"center\">Identifiant</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Marque</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Date de fabrication</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Type</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Puissance</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Quantite d'huile</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">PCB</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Valeur</td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Poste de stockage </td> <td colspan=\"1\" rowspan=\"2\" align=\"center\">Modifier </td> </tr> <tr> </tr>" ); //affichage des données: while( $result = mysql_fetch_array( $requete ) ) { echo( "<tr>\n" ); echo( "<td><div align=\"center\">".$result['identifiant']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['marque']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['date_fabrication']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['type']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['puissance']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['qtite_huile']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['pcb']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['valeur']."</div></td>\n" ); echo( "<td><div align=\"center\">".$result['zone']."</div> </td>\n" ); echo("<td><div align=\"center\"> <a href=\"affiche1.php?idtransfo='".$result['identifiant']."'\">Modifier</a></div></td>\n") ; echo( "</tr>\n" ); } echo( "</table><br>\n" ); } ?> </body> </html>
Partager