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 74 75 76 77 78 79 80 81 82
| <head>
<title>Infocontact</title>
</head>
<body style="background-color: silver;">
<a href="101_nouveaucontact.php">Acceuil</a><br>
<?php
if(isset($_POST['quitter'])){
header("location: http://localhost/Tableau%20de%20bord/mabase/");
}
//Intégrer le fichier des fonctions
include("01_fonction.php");
if(isset($_POST['info'])){
$info=$_POST['info'];
}
?>
<h2>Vous souhaitez voir les coordonnées de :</h2>
<form name="info" method="post" action="102_infocontact.php">
<p><select name="info">
<?php
connectmabase();
$sql = "select distinct nom from abonnes";
$rep = mysql_query("$sql") ;
while($table_col = mysql_fetch_array($rep))
{
echo "<option>".$table_col[nom]."</option>";
}
?>
<input type="submit" name="valider" value="Valider"/>
</select><br/></p>
<p><?php
/*attention à la gestion des libérations de mémoire
c'est à la fin de chaque requête différente
Plusieurs peuvent donc se succéder
tandis que la connexion à la base et la déconnexion
ne se font qu'une seule fois quand la base entre ou sort du jeu*/
//Commun à n'importe quelle option
if (isset ($_POST['info'])){
//connexion initiale de la db
connectmabase();
//Gérer chaque choix :
//if($info=='nom'){
// $sql='SELECT * from abonnes WHERE nom';
$sql="SELECT * from abonnes WHERE nom='".$_POST['info']."'";
$requete = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
while ($table_col = mysql_fetch_array($requete)) {
echo $table_col['prenom'].' '.$table_col['nom']. '<br/>';
echo '<strong>Adresse :</strong>' .$table_col['adresse']. '<br/>';
echo '<strong>Ville : ' .$table_col['ville'].'</strong><br/>';
echo $table_col['cp'];
}
mysql_free_result ($requete);
}
else{
echo'Vous n\'avez rien sélectionné ?';
}
//clôture finale de la db
mysql_close ();
//}
?></p>
<p><input type="submit" name="quitter" value="quitter"/></p>
</form>
</body> |
Partager