Affichage d'un tableau en fonction d'une list
twa4ever
Messages postés
92
Statut
Membre
-
twa4ever Messages postés 92 Statut Membre -
twa4ever Messages postés 92 Statut Membre -
Bonjour,
Je souhaiterais afficher des données dans mon tableau en fonction du nom choisit dans la liste déroulante, j'ai essayé tout simplement dans ma requete avec "where" mais ça ne marche pas.
Comment puis je faire?
Merci de votre aide, voici mon code :
<?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 personnel";
//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><br>
</form>
<form>
<table border bodercolordark="black" align = "center" cellpadding="10"><tr>
<th>Date Demande</th>
<th>Objet mission</th>
<th>Nom</th>
<th>Type transport</th>
<th>Réduction en %</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 where Nom = "'.$data3["Nom"].'"');
$sql_affichage = mysql_query('SELECT * FROM voyage');
while ($donnees = mysql_fetch_array($sql_affichage))
{
?>
<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['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>
</tr>
<?php
}
?>
</table>
<tr>
</form>
Je souhaiterais afficher des données dans mon tableau en fonction du nom choisit dans la liste déroulante, j'ai essayé tout simplement dans ma requete avec "where" mais ça ne marche pas.
Comment puis je faire?
Merci de votre aide, voici mon code :
<?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 personnel";
//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><br>
</form>
<form>
<table border bodercolordark="black" align = "center" cellpadding="10"><tr>
<th>Date Demande</th>
<th>Objet mission</th>
<th>Nom</th>
<th>Type transport</th>
<th>Réduction en %</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 where Nom = "'.$data3["Nom"].'"');
$sql_affichage = mysql_query('SELECT * FROM voyage');
while ($donnees = mysql_fetch_array($sql_affichage))
{
?>
<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['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>
</tr>
<?php
}
?>
</table>
<tr>
</form>
A voir également:
- Affichage d'un tableau en fonction d'une list
- Tableau word - Guide
- Fonction si et - Guide
- Trier un tableau excel - Guide
- Comment imprimer un tableau excel sur une seule page - Guide
- Code ascii tableau - Guide