Bonjour,
J'ai créer un formulaire de recherche très simple..
Pour la page rechercherep j'ai procédé comme il suit :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <?php echo' <form method="post" action="Rechercherep.php"/> <input type="text" name="recherche"/> <input type="submit" value="Rechercher un utilisateur"/> </form>'; ?>
Sur mon site, quand j'effectue une recherche par rapport au login.. au lieu de m'afficher un seul résultat, pour l'ordinateur correspondant au compte utilisateur, il m'affiche les 6 ordinateurs présents dans ma base de donnée.. je n'arrive pas a comprend pourquoi il me prend tout ces champs...
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 $recherche=$_POST['recherche']; $req="select * from ordinateur, utilisateur where ordinateur.IdUser=utilisateur.IdUser and RAM like '%$recherche%' or CPU like '%$recherche%' or DD like '%$recherche%' or Login like '%$recherche%' or NomPoste like '%$recherche%'"; $query = mysql_query($req, $connexion) or die("erreur".mysql_error()); $lgreq = mysql_fetch_array($query); if(empty($_POST['recherche'])) { echo' <div id="background"> <div id="page"> <div class="header"> <div class="footer"> <div class="body"><div id="sidebar"> <a href="index.html"><img id="logo" src="images/logo.gif" with="154" height="74" alt="" title=""/></a> <ul class="navigation"> <li><a href="index.html">Accueil</a></li> <li class="active"><a href="gestion.php" >Gestion du Parc</a></li> <li><a href="about.php">A propos</a></li> <li class="last"><a href="contact.php">Contact</a></li> </ul> <div class="footenote"> <span>© Copyright © 2011.</span> <span><a href="index.html">Smart&Co</a> all rights reserved</span> </div> </div> <div id="content"> <div class="content"> <div class="icones"> <p>'; echo '<h2>Veuillez saisir un champ pour votre recherche<h2>'; echo' </div> </div> </div> </div> </div> </div> </div> </div>'; header("Refresh: 1; URL=gestion.php"); } else { if (mysql_num_rows($query) > 0) { echo '<div id="background"> <div id="page"> <div class="header"> <div class="footer"> <div class="body"><div id="sidebar"> <a href="index.html"><img id="logo" src="images/logo.gif" with="154" height="74" alt="" title=""/></a> <ul class="navigation"> <li><a href="index.html">Accueil</a></li> <li class="active"><a href="gestion.php" >Gestion du Parc</a></li> <li><a href="about.php">A propos</a></li> <li class="last"><a href="contact.php">Contact</a></li> </ul> <div class="footenote"> <span>© Copyright © 2011.</span> <span><a href="index.html">Smart&Co</a> all rights reserved</span> </div> </div> <div id="content"> <div class="content"> <div class="tableau"> <p>'; echo'<center><table border="1" width="75%"></center>'; echo '<tr><th>Nom du poste</th><th>Login</th><th>Ram</th><th>DD</th><th>CPU</th><th>Détails</th></tr>'; echo'</br>'; // BOUCLE SUR LES ECRANS while ($lgreq != FALSE) { $NomPoste = $lgreq['NomPoste']; $login = $lgreq['Login']; $ram = $lgreq['RAM']; $cpu = $lgreq['CPU']; $DD = $lgreq['DD']; echo ' <tr> <td align="center">'.$NomPoste.'</td> <td align="center">'.$login.'</td> <td align="center">'.$ram.'</td> <td align="center">'.$DD.'</td> <td align="center">'.$cpu.'</td> <td align ="center"><a href="detailordi.php?NomPoste='.$NomPoste.'"><img src="images/oeil.png" border="0" alt="user" /></a></a></td> </tr>'; $lgreq=mysql_fetch_array($query); } echo '</table>'; echo' </div> </div> </div> </div> </div> </div> </div> </div>'; } else { echo' <div id="background"> <div id="page"> <div class="header"> <div class="footer"> <div class="body"><div id="sidebar"> <a href="index.html"><img id="logo" src="images/logo.gif" with="154" height="74" alt="" title=""/></a> <ul class="navigation"> <li><a href="index.html">Accueil</a></li> <li class="active"><a href="gestion.php" >Gestion du Parc</a></li> <li><a href="about.php">A propos</a></li> <li class="last"><a href="contact.php">Contact</a></li> </ul> <div class="footenote"> <span>© Copyright © 2011.</span> <span><a href="index.html">Smart&Co</a> all rights reserved</span> </div> </div> <div id="content"> <div class="content"> <div class="icones"> <p>'; echo '<h2>Aucun résultat pour votre recherche<h2>'; echo' </div> </div> </div> </div> </div> </div> </div> </div>'; header("Refresh: 1; URL=gestion.php"); } echo' </div> </div> </div> </div> </div> </div> </div> </div>'; }
Nom du poste Login Ram DD CPU Détails
CFG0204201102 j.ayo 4 500 i5
CFG0204201103 j.ayo 4 500 i5
CFG0204201104 j.ayo 4 500 i5
CFG0204201105 j.ayo 4 500 i5
CFG0204201101 j.ayo 4 500 i5
CFG0204201106 j.ayo 4 500 i5
Merci pour votre aide
Cordialement
Partager