Pb formulaire php : liste deroulante

Résolu/Fermé
Marion25 - 24 mars 2009 à 19:05
 Marion25 - 24 mars 2009 à 21:27
Bonjour,

Voici mon problème en esperant que vous pourriez m'aider. Voici un formulaire php qui récupère des données de ma base Mysql sous forme de tableau.Au dessus de ce tableau une liste déroulante avec des noms.
J'aimerais pouvoir afficher des données du tableau en fonction du nom choisit dans la liste déroulante.J'ai essayé tout simplement de mettre dans le "where" de la requete sql mais ça ne marche pas.

voici mon code :

<html>
<head>
<title>Affichage</title>
<link href="style.css" rel="stylesheet" media="all" type="text/css">
</head>
<body>

<center><h1 style="color: #923232;font-size: 400%;font-family: Complete in Him" >Liste des voyages</center></h1>
<p style="color: black ; font-family: tahoma, sans-serif ; ">
<form name="monForm" action="transfert.php " method="POST" >

<?php
$connexion = mysql_connect("localhost","root","");
if ($connexion)
{
mysql_select_db("voyage",$connexion);


?>
Veuillez sélectionner le nom d'un salarié : <select>
<Option value="-1">-- Nom --</Option>
<?php

//on se connecte à MySQL
$db = mysql_connect('localhost', 'root', '') ;

//on sélectionne la base
mysql_select_db('Intranet',$db) ;

$sql3 = "SELECT distinct Nom FROM voyage";
//on envoie la requête
$req3 = mysql_query($sql3) or die(mysql_error());

//on fait une boucle qui va faire un tour pour chaque enregistrement
while($data3 = mysql_fetch_assoc($req3))

//on affiche les informations de l'enregistrement en cours
{
echo "<option value>" .$data3['Nom']. "</option>";

}
//on ferme la connexion à mysql
mysql_close();
}
?>
</select>
<br><br>

</form>
<form>


<table border bodercolordark="black" align = "center" cellpadding="10"><tr>
<th>Date Demande</th>
<th>Objet mission</th>
<th>Nom</th>
<th>Prenom</th>
<th>Type transport</th>
<th>Réduction</th>
<th>Ville de départ</th>
<th>Ville d'arrivée</th>
<th>Date de départ</th>
<th>Heure de départ</th>
<th>Date de retour</th>
<th>Heure de retour</th>
<th>Demande d'hotel ?</th>
<th>Nom de l'hotel n°1</th>
<th>Nom de l'hotel n°2</th>
<th>Nom de l'hotel n°3</th>
<th>Type de chambre</th>
<th>Fumeur ?</th>
<th>Arrivée après 18H ?</th>
<th>Nombre de nuits</th>
</tr>
<?php
$connexion = mysql_connect("localhost","root","");
Mysql_select_db("Intranet",$connexion);

$sql_affichage = mysql_query('SELECT * FROM voyage');
while ($donnees = mysql_fetch_array($sql_affichage)) // On fait une boucle pour lister les résultats
{
?>
<tr>
<td>
<?php echo $donnees['Date_demande']; ?>
</td><td>
<?php echo $donnees['Objet_mission']; ?>
</td><td>
<?php echo $donnees['Nom']; ?>
</td><td>
<?php echo $donnees['prenom']; ?>
</td><td>
<?php echo $donnees['Type_transport']; ?>
</td><td>
<?php echo $donnees['Reduction']; ?>
</td><td>
<?php echo $donnees['Ville_depart']; ?>
</td><td>
<?php echo $donnees['Ville_arrivee']; ?>
</td><td>
<?php echo $donnees['Date_depart']; ?>
</td><td>
<?php echo $donnees['Heure_depart']; ?>
</td><td>
<?php echo $donnees['Date_retour']; ?>
</td><td>
<?php echo $donnees['Heure_retour']; ?>
</td><td>
<?php echo $donnees['Hotel_oui_non']; ?>
</td><td>
<?php echo $donnees['Nom_hotel1']; ?>
</td><td>
<?php echo $donnees['Nom_hotel2']; ?>
</td><td>
<?php echo $donnees['Nom_hotel3']; ?>
</td><td>
<?php echo $donnees['type_chambre']; ?>
</td><td>
<?php echo $donnees['Fumeur_oui_non']; ?>
</td><td>
<?php echo $donnees['Arriver_ap_18h']; ?>
</td><td>
<?php echo $donnees['Nb_nuit']; ?>
</td><td>
</tr>

<?php
} // Fin de la boucle
?>

</table>
<tr>
</form>

</body>
</html>

4 réponses

atspinto Messages postés 338 Date d'inscription samedi 30 août 2008 Statut Membre Dernière intervention 8 août 2014 27
24 mars 2009 à 19:40
qu'est ce qui ne marche pas : le 2e select ou la selection en fonction du nom du voyageur ??
0
ce qui ne marche pas c'est afficher les données du tableau en fonction du nom :$
0
atspinto Messages postés 338 Date d'inscription samedi 30 août 2008 Statut Membre Dernière intervention 8 août 2014 27
24 mars 2009 à 20:01
echo "<option value>" .$data3['Nom']. "</option>";

t'as dû oublier un truc dans l'affichage des noms selectionnés.....
<option value="ma valeur"> texte </option>
0
Je ne sais pas trop à vrai dire je débute :s
0