Probleme condition IF
Résolu
biogould
-
luc648 Messages postés 604 Statut Membre -
luc648 Messages postés 604 Statut Membre -
Bonjour,
alors j'expose mon probleme de condition; j'ai un menu deroulant :
qui me permet de generer un tableau selon l'option choisie.
JE souhaite que en recuperant mon id et selon si c'est 'entreprise' ou 'etudiant' ou autre j'ai mon tableau correspondant, sauf que j'ai mes deux tableau qui s'affichent l'un en dessous de l'autre. je ne comprend pas car mes variable 'id' changent bien selon l'option choisit :
Dans l'attente , merci
alors j'expose mon probleme de condition; j'ai un menu deroulant :
<center> <form action="historique2.php" method="POST"> <select name="id"> <option value="entreprise">Entreprise</option> <option value="etudiant">Etudiant</option> <option value="annee">Année</option> <option value="classe">Classe</option> <option value="professeur">Professeur </option> <p> <input type="submit" value="Ok"> </p> </select> </form>
qui me permet de generer un tableau selon l'option choisie.
JE souhaite que en recuperant mon id et selon si c'est 'entreprise' ou 'etudiant' ou autre j'ai mon tableau correspondant, sauf que j'ai mes deux tableau qui s'affichent l'un en dessous de l'autre. je ne comprend pas car mes variable 'id' changent bien selon l'option choisit :
<?php
if ($_POST['id']="etudiant");
{
$sql1 ="select * from etudiant";
$r1=mysql_query($sql1) or die('Erreur SQL !'.$sql1.mysql_error());
?>
<center>
<table width="90%" border="1">
<tr>
<td width="20"><b>id</td>
<td width="250"><b>Nom</td>
<td width="250"><b>Prénom</td>
<td width="250"><b>Date de naissance</td>
</tr>
<?php
while ($ligne=mysql_fetch_array($r1))
{
echo "<tr><td>";
echo'<a href="pdf_historique.php?id='.$ligne['id_etudiant'].'">'.$ligne['id_etudiant'].'</a>';
echo "</td><td>" ;
echo $ligne['nom_etudiant'];
echo "</td><td>";
echo $ligne['prenom_etudiant'];
echo "</td><td>";
echo $ligne['datenaissance'] ;
echo "</td><tr>" ;
}
}
if ($_POST['id']="entreprise");
{
$sql2 ="select * from entreprise";
$r2=mysql_query($sql2) or die('Erreur SQL !'.$sql2.mysql_error());
?>
<center>
<table width="90%" border="1">
<tr>
<td width="250"><b>Nom </td>
<td width="250"><b>Adresse </td>
<td width="250"><b>E-mail</td>
<td width="250"><b>Téléphone</td>
<td width="250"><b>Fax</td>
</tr>
<?php
while ($ligne=mysql_fetch_array($r2))
{
echo "<tr><td>";
echo $ligne['nom_entreprise'];
echo "</td><td>";
echo $ligne['rue_entreprise'];
echo "</td><td>";
echo $ligne['email_entreprise'] ;
echo "</td><td>";
echo $ligne['tel_entreprise'];
echo "</td><td>";
echo $ligne['fax_entreprise'];
echo "</td><tr>" ;
}
}
?>
Dans l'attente , merci
A voir également:
- Probleme condition IF
- Excel cellule couleur si condition texte - Guide
- Excel condition ou - Guide
- Condition optimale téléphone ✓ - Forum Mobile
- If exist ✓ - Forum Autoit / batch
- The realtek network controller was not found. if deep sleep mode is enabled please plug the cable ✓ - Forum Pilotes (drivers)
3 réponses
salut ,
dans ton if il ne faut pas mettre if ($_POST['id']="etudiant")
mais if ($_POST['id']=="etudiant")
il faut 2 == pour un comparateur d'égalité
1 seul = c'est pour attribuer une valeur a une variable
puis il ne faut pas mettre ; derrière un if
dans ton if il ne faut pas mettre if ($_POST['id']="etudiant")
mais if ($_POST['id']=="etudiant")
il faut 2 == pour un comparateur d'égalité
1 seul = c'est pour attribuer une valeur a une variable
puis il ne faut pas mettre ; derrière un if