Developpementphp

info254 -  
giheller Messages postés 1960 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
je veux crée un menu déroulant dynamique cad les choix de cet menu sont les utilisateur de ma table utilisateur
et ca marche et voila mon code de 1ere page php"liste5.php"

<!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>
<title>Untitled Document</title>
</head>

<body>
<form method="POST" name="forme14" action="liste6.php" >
<SELECT name="listeclients" id="listeclients">
<?php // onchange="function1(menu)"
$connexion=mysql_connect('localhost','root','');
$db=mysql_select_db('grh',$connexion);

$sql = "SELECT distinct prenom FROM employer order by prenom";
$reponse = mysql_query($sql);
while($donnees = mysql_fetch_array($reponse))
{
?>
<option value="<?php $donnees['prenom'] ?>" ><?php echo $donnees['prenom'] ?></option>
<?php } ?>
<input type="submit" value="ok" name="ok" />
</form>
</body>
</html>
mais quand je choisi une choix et je clik sur le bouton ok il m'affiche seulement le tableau vide
et voila le code de 2eme page php"liste6.php"

html>
<body background="Images/traçage-yogo-elipse_03.gif">
<font color="#00FF00"></font>
<?php
$dbhost="localhost";
$user="root";
$usebdd="grh";
$listeclients=$_POST['listeclients'];

$connexion=mysql_connect($dbhost,$user) or die('erreur connexion'); // sélection de la base
mysql_select_db($usebdd,$connexion) or die('erreur connexion a la base'); //connexio a la base

$req1= "SELECT * FROM employer as emp, contrat as con , categorie as categ, service as ser WHERE emp.ncin=con.ncin and categ.ncin=emp.ncin and emp.ncin=ser.ncin and emp.prenom='$listeclients' ";
$resultat1=mysql_query($req1);
$lig=mysql_fetch_row($resultat1);
//$num_rows=mysql_num_rows($resultat1);
if($resultat1)
//if($resultat1)
{echo'<div align="center">';
echo"<b> Modification</b><br>";
echo"<form action='' name='for' method='post' enctype='multipart/form-data' >";
echo"<table border=1 bordercolor='#0000FF' align='center' bgcolor='#0000FF'>";echo"<tr>";
echo"<tr>";echo"<th>Nom</th>";
echo"<td><b><input type='text' size='20' name='nom' value='$lig[5]'></b></td>";
echo"</tr>";
echo"<tr>";echo"<th>Prénom</th>";
echo"<td><b><input type='text' size='20' name='prenom' value='$lig[6]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Date de Naissance</th>";
echo"<td><b><input type='text' size='20' name='datenaissance' value='$lig[7]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Lieu de Naissance</th>";
echo"<td><b><input type='text' size='20' name='lieunaissance' value='$lig[8]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Ncin</th>";
echo"<td><b><input type='text' size='20' name='ncin' value='$lig[0]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Date-cin</th>";
echo"<td><b><input type='text' size='20' name='datecin' value='$lig[1]' maxlength='8'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Matricule CNSS</th>";
echo"<td><b><input type='text' size='20' name='matcnss' value='$lig[2]' maxlength='10'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Date-declaration-CNSS</th>";
echo"<td><b><input type='text' size='20' name='datedeclarcnss' value='$lig[3]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Matricule-emp</th>";
echo"<td><b><input type='text' size='20' name='matempl' value='$lig[4]' maxlength='3'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Adresse</th>";
echo"<td><b><input type='text' size='20' name='adresse' value='$lig[9]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>N°-Tel</th>";
echo"<td><b><input type='text' size='20' name='numtel' value='$lig[10]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Date d'entré</th>";
echo"<td><b><input type='text' size='20' name='dateentrer' value='$lig[11]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Niveau</th>";
echo"<td><b><input type='text' size='20' name='niveau' value='$lig[12]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Etatcivil</th>";
echo'<td><select name="etatcivil">
<option>Célibataire</option>
<option>Marié(e)</option>
<option>Divorcé(e)</option>
<option>Veuf</option>
<option>Séparé</option>
</select></td>';echo"</tr>";
echo"<tr>";echo"<th>Nombre des enfants</th>";
echo"<td><b><input type='text' size='20' name='nbrenfants' value='$lig[14]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Etat</th>";
echo'<td><select name="etat">
<option>Titulaire</option>
<option>Contractuel</option>
<option>Occasionnel
<option>Stagaire</option>
<option>SIVP</option>
<option>E.F</option>
<option>Saissonnier</option></select></td>';echo"</tr>";
echo"<tr>";echo"<th>Usine</th>";
echo'<td><select name="usine">
<option>Soril</option>
<option>Sodipral</option></select></td>';echo"</tr>";

echo"<tr>";echo"<th>Categorie</th>";
echo"<td><b><input type='text' size='20' name='categ' value='$lig[22]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Degré</th>";
echo"<td><b><input type='text' size='20' name='degre' value='$lig[23]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Echlon</th>";
echo"<td><b><input type='text' size='20' name='echlon' value='$lig[24]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Date debut degré</th>";
echo"<td><b><input type='text' size='20' name='datedebutdegre' value='$lig[25]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Date fin degré</th>";
echo"<td><b><input type='text' size='20' name='datefindegre' value='$lig[26]'></b></td>";echo"</tr>";

echo"<tr>";echo"<th>N° Contrat</th>";
echo'<td><select name="numcontrat">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option></select></td>';echo"</tr>";
echo"<tr>";echo"<th>Date debut Contrat</th>";
echo"<td><b><input type='text' size='20' name='datedebut' value='$lig[19]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Date fin contrat</th>";
echo"<td><b><input type='text' size='20' name='datefin' value='$lig[20]'></b></td>";echo"</tr>";

echo"<tr>";echo"<th>Poste</th>";
echo"<td><b><input type='text' size='20' name='poste' value='$lig[28]'></b></td>";echo"</tr>";
echo"<tr>";echo"<th>Service</th>";
echo'<td><select name="nomservice">
<option>Direction adm-finan</option>
<option>Direction général</option>
<option>Direction commercial</option>
<option>Informatique</option>
<option>Maintenance</option>
<option>Production</option>
<option>Sécurité</option>
</select></td>';echo"</tr>";
echo"<tr>";echo"<th>Unité</th>";
echo"<td><b><input type='text' size='20' name='unite' value='$lig[30]'></b></td>";echo"</tr>";
echo"</tr>";
echo"<tr><td colspan='2' align='center'>";
echo"<input type='submit' value='ok'>"; echo"<input type='reset' value='Effacer'>";
echo"</table>";echo'</div>';echo"</form>";
}
?>
<table width="15%" bgcolor="#0000FF" align="center"><tr><td>
<a href="modifier person.html"><b><i><h2><font color="#FFFFFF">Précédent</font></h2></i></b></a></td><td><a href="#" onClick="window.close();"><b><i><h2><font color="#FFFFFF">Fermer</font></h2></i></b></a></td><td> <a href="menugrh.html"><b><i><h2><font color="#FFFFFF">Menu</font></h2></i></b></a></td></tr></table></td></pre>

</body></html>

21 réponses

giheller Messages postés 1960 Date d'inscription   Statut Membre Dernière intervention   146
 
bonjour,

j'ai repris le début de liste6.php pour tester chez moi.
le codes est donc :
<?php
$listeclients="Amandine";//$_POST['listeclients'];

/* coonexion à la base de donnnées locale WXP*/
#specify the connection information
$db_server ="localhost";
$db_name = "xxxxx";
$username = "root";
$password = "mysql";

#Connexion à la base
$dbh = @mysql_connect($db_server,$username,$password) or die
("La connection sur $db_server avec le login '$username'/'$password' plantée.");

#select the database. If the database is not found on the server, let us know
$db = @mysql_select_db($db_name) or die
("Connection made. But database '$db_name' was not found.");

$req1= "SELECT * FROM societes WHERE soc_nom='$listeclients' ";
$resultat1=mysql_query($req1);
$lig=mysql_fetch_row($resultat1);
//$num_rows=mysql_num_rows($resultat1);
if($resultat1) {
echo "<pre>";print_r($lig);echo "</pre>";
}
?>

le résultat est
Array
(
[0] => 3
[1] => 12
[2] => Amandine
[3] => amandine.php
)

comme tu peux le constater ce code fonctionne.
si donc tu n'affiche rien,
1 regarde au début ce que contient le tableau $_POST
ici dans ton code :
<?php
$dbhost="localhost";
$user="root";
$usebdd="grh";
$listeclients=$_POST['listeclients'];

echo "<pre>";print_r($_POST);echo "</pre>";

2 vérifie si la requête retourne quelque chose.

0