Bonjour,
j'ai un petit probleme pour fermer une boucle simple php qui est en conflit avec deuxieme de Mysql, car l'objectif est d'avoir un message de confirmation de la rechercher effectué en indiquant le nom tapé de la recherche, pour cela :
J'ai mis une condition If au milieu de mon tableau html, pour afficher le nom tapé de la recherche, deplus la boucle while pour mon tableau est obligatoire, pour afficher les resultats dans le tableau
je n'arrive pas a mettre deux fermeture de boucles ( } ) etant donnée qu'il y en a deux autre plus bas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <?php while($ligne=mysql_fetch_array($resultat)){ if($requete) { echo '<div align="center"><font face="arial" size="4" color="red">Résultat de votre recherche celon : '.$nom.'. <p>Listing ! </p></font></div> '; } ?>
dans le tableau il me faut la boucle pour afficher tout les resultat, voila pourquoi j'utilise while
etc...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <tr> <th scope="row"><?php echo $ligne['id']?></th> <td><?php echo $ligne['Societe']?></td> <td><?php echo $ligne['Nom']?></td>
Plus bas pour fermer la boucle de mon tableau html j'ai mis
Tout le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <?php //echo $ligne['id']. $ligne['Nom']."<br/>" ; } }//toute la ligne est comprise dans la boucle while ?>
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 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Recherche d'un nom dans l'annuaire téléphonique</title> <style type="text/css"> <!-- .Style1 {color: #FF0000} --> </style> </head> <body> <?php // Connexion a la BDD avec login.php require ('login.php'); $link = mysql_connect("$hote", "$login", "$pass"); //or die("Erreur de connexion...") ; $req = mysql_select_db($bdd, $link) or die("Erreur de connexion...") ; /* ------------------ A PARTIR D'ICI COMMANDE DU BOUTON : RECHERCHE APPROXIMATIVE ------------------ */ if(isset($_POST['envoyer-recherche-approximative'])) { $nom = mysql_real_escape_string(htmlspecialchars($_POST['nom'])); $requete= "SELECT * FROM telephonique WHERE Nom LIKE '$nom%'"; $resultat = mysql_query($requete) or die(mysql_error()); ?> <?php echo $ligne['Adresse1']?> <table width="1493" border="1"> <tr> <th width="17" scope="col">Id</th> <th width="49" scope="col">Société</th> <th width="32" scope="col">Nom</th> <th width="51" scope="col">Prénom</th> <th width="80" scope="col">Date de naissance </th> <th width="63" scope="col">Adresse1</th> <th width="63" scope="col">Adresse2</th> <th width="45" scope="col">Code Postal </th> <th width="31" scope="col">Ville</th> <th width="32" scope="col">Pays</th> <th width="74" scope="col">Téléphone fixe </th> <th width="74" scope="col">Téléphone internet </th> <th width="74" scope="col">Téléphone portable </th> <th width="69" scope="col">Opérateur</th> <th width="25" scope="col">Fax</th> <th width="46" scope="col">Email1</th> <th width="46" scope="col">Email2</th> <th width="76" scope="col">Messenger</th> <th width="439" scope="col">Remarque</th> </tr> <tr> <th scope="row"> </th> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <?php while($ligne=mysql_fetch_array($resultat)){ if($requete) { echo '<div align="center"><font face="arial" size="4" color="red">Résultat de votre recherche celon : '.$nom.'. <p>Listing ! </p></font></div> '; } ?> <tr> <th scope="row"><?php echo $ligne['id']?></th> <td><?php echo $ligne['Societe']?></td> <td><?php echo $ligne['Nom']?></td> <td><?php echo $ligne['Prenom']?></td> <td><?php echo $ligne['date_de_naissance']?></td> <td><?php echo $ligne['Adresse1']?></td> <td><?php echo $ligne['Adresse2']?></td> <td><?php echo $ligne['Code_Postal']?></td> <td><?php echo $ligne['Ville']?></td> <td><?php echo $ligne['Pays']?></td> <td><?php echo $ligne['Telephone_Fixe']?></td> <td><?php echo $ligne['Telephone_Internet']?></td> <td><?php echo $ligne['Telephone_portable']?></td> <td><?php echo $ligne['Operateur']?></td> <td><?php echo $ligne['Fax']?></td> <td><?php echo $ligne['Email1']?></td> <td><?php echo $ligne['Email2']?></td> <td><?php echo $ligne['Messenger']?></td> <td><?php echo $ligne['Remarque']?></td> </tr> <?php } }//toute la ligne est comprise dans la boucle while ?> </table> </p> <p align="center">Recherche d'un nom dans l'annuaire téléphonique, Veuillez indiquer ci-dessous le nom dans le champs pour effectuer une recherche. (<span class="Style1">*</span>) Champs obligatoire. <form action="" method='post'> </p> <table align="center" border="0"> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Recherche (<span class="Style1">*</span> )</td> <td><input type="text" name="nom" size="20" maxlength="20" /></td> <td><input type="submit" name="envoyer-recherche-approximative" value="Rechercher"></td> </tr> </table> <p> </p> <p align="center"> <td><FORM> <INPUT TYPE="button" VALUE="Retour" onClick="history.back()"> </FORM> <p> </p> </body> </html> <?php mysql_close(); ?>
Partager