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
| <?php
// information pour la connection à le DB
$host = 'localhost';
$user = 'root';
$pass = '';
$db = 'auffargis';
// Affiche les resultat d'un requete dans une liste déroulante
echo "<select>";
// connection à la DB
$link = mysql_connect($host,$user,$pass) or die ('Erreur : '.mysql_error() ); // Connexion à MySQL
mysql_select_db($db) or die ('Erreur :'.mysql_error() ); // Sélection de la base auffargis
$requete=mysql_query("SELECT nom FROM licencies order by nom");
$nombrelignes = mysql_num_rows($requete);
for ($i=0;$i<$nombrelignes;$i++) {
$nom = mysql_result($requete,$i,"nom");
echo "<option value=$nom>$nom </option>";
}echo '
</select>';
if(isset($_GET['$nom']))
$_GET['$nom']=$nom;
{
$requet = mysql_query("SELECT * FROM licencies WHERE nom LIKE '".$_GET['$nom']."%'");
$combien = mysql_num_rows($requet);
}
if($combien) {
// début du tableau
echo '<table bgcolor="#FFFFFF">'."\n";
// première ligne on affiche les titres
echo '<tr>';
echo '<td bgcolor="#669999"><b><u>Nom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Prénom</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Adresse</u></b></td>';
echo '<td bgcolor="#669999"><b><u>CP</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Ville</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Tel Fixe</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Tel Mobile</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Tel IP</u></b></td>';
echo '<td bgcolor="#669999"><b><u>Sexe</u></b></td>';
echo '<td bgcolor="#669999"><b><u>FFST</u></b></td>';
echo '<td bgcolor="#669999"><b><u>FFPJP</u></b></td>';
echo '</tr>'."\n";
// lecture et affichage des résultats
while($row = mysql_fetch_array($requet)) {
echo '<tr>';
echo '<td bgcolor="#CCCCCC">'.$row['nom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['prenom'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['adresse'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['code_postal'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['ville'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['tel_fixe'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['tel_mobile'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['tel_ip'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['sexe'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['lic_ffst'].'</td>';
echo '<td bgcolor="#CCCCCC">'.$row['lic_ffpjp'].'</td>';
echo '</tr>'."\n";
}
echo '</table>'."\n";
// fin du tableau.
}
else echo 'Pas d\'enregistrements dans cette table...';
// on libère le résultat
mysql_free_result($requet);
mysql_close(); // Déconnexion de MySQL
?> |
Partager