1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
<?php
$id = mysql_connect("localhost", "root", "") or die("Impossible de se connecter".mysql_error());
mysql_select_db("base");
if (isset($_POST['rechercher'])) //si on a validé le formulaire
{
$nom = mysql_real_escape_string(htmlspecialchars($_POST['nom']));
$prenom = mysql_real_escape_string(htmlspecialchars($_POST['prenom']));
$query = mysql_query("select fonctionnaire.ppr, etre_humain.nom, etre_humain.prenom,fonctionnaire.tel_post,etre_humain.e_mail from fonctionnaire, etre_humain WHERE etre_humain.CIN=fonctionnaire.CIN AND prenom LIKE '%$prenom%' AND nom LIKE '%$nom%' ") or die (mysql_error());
$nb_resultats = mysql_num_rows($query); // on utilise la fonction mysql_num_rows pour compter les résultats pour vérifier par après
if($nb_resultats != 0) // si le nombre de résultats est supérieur à 0, on affiche les résultats
{
echo 'Nous avons trouvé '.$nb_resultats.' '; // on affiche le nombre de résultats
if($nb_resultats > 1) { echo 'résultats'; } else { echo 'résultat'; }
?>
<table width="375" border="1">
<tr>
<th width="25" height="25" scope="col">PPR</th>
<th width="49" scope="col">Nom</th>
<th width="65" scope="col">prénom</th>
<th width="53" scope="col">tél poste</th>
<th width="49" scope="col">E-mail</th>
<th width="103" scope="col">Action</th>
</tr>
<?php
while($donnees = mysql_fetch_array($query)) // on fait un while pour afficher la liste des fonctions trouvées, ainsi que l'id qui permettra de faire le lien vers la page de la fonction
{ ?>
<tr>
<th scope="col">
<?php echo ''.$donnees['ppr'].''; ?>
</th>
<th scope="col">
<?php echo ''.$donnees['nom'].''; ?>
</th>
<th scope="col">
<?php echo ''.$donnees['prenom'].''; ?>
</th>
<th scope="col">
<?php echo ''.$donnees['tel_post'].''; ?>
</th>
<th scope="col">
<?php echo ''.$donnees['e_mail'].''; ?>
</th>
<th scope="col">
<p><span id="spryselect1">
<label for="select1"></label>
<label for="select"></label>
<select name="select" id="select">
<option>---</option>
<option>Edition</option>
<option>Consutation</option>
</select>
<span class="selectRequiredMsg">Please select an item.</span></span></p>
<</th>
</tr>
<?php
} // fin de la boucle
?>
</table>
<br/><input type="submit" name="ok" value="ok">
<?php
} //fin du If
else{ ?>
<p>Nous n'avons trouvé aucun résultat pour votre requête <? echo $_POST['requete']; ?> <a href="acceuil.php">Réessayez</a> avec autre chose.</p>
<?php
}// Fini d'afficher l'erreur
mysql_close($id); // on ferme mysql, on n'en a plus besoin
}
?> |
Partager