Bonjour,
j'ai un petit soucis concernant le remplissage de ma liste déroulante.
La table est t_catalogue_cat qui a pour attribut :
- cat_id (identifiant qui s'auto incrémente)
- cat_Nom (Varchar)
J'aimerai remplir ma liste déroulante avec tous les cat_Nom présent dans la table voici mon code :
Merci de vos réponses,
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 <?php try { $bdd = new PDO('mysql:host=localhost;dbname=projet_web','root', '',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); $reponse = $bdd->query('SELECT cat_Nom FROM t_catalogue_cat'); echo '<select name="cat_Nom">'; while ($donnees = $reponse->fetch()) { echo '<option value=' . htmlspecialchars($donnees['cat_Nom']) . '>' . htmlspecialchars($donnees['cat_Nom']) . '</option>'; } echo '</select>'; }catch(Exception $e){ die('Erreur : '.$e->getMessage()); } ?>
Cdtl,
Partager