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
| <?php
connectmabase();
echo '<h2>Vous souhaitez voir les coordonnées de :</h2>
<form method="post" action="">';
if (isset($_POST['nom'])) {
echo '<p>' . $_POST['nom'] . '</p>';
echo '<select name="id">';
$sql="SELECT id, prenom from abonnes WHERE nom='".mysql_real_escape_string($_POST['info'])."'";
$rep = mysql_query($sql);
while($table_col = mysql_fetch_array($rep)) {
echo '<option value="' .$table_col['id'] . '" >'.$table_col['prenom'].'</option>';
}
echo '</select>';
}
else {
echo '<select name="nom">':
$sql = "select distinct nom from abonnes";
$rep = mysql_query($sql);
while($table_col = mysql_fetch_array($rep)) {
echo '<option="' .$table_col['nom'] . '" >'.$table_col['nom'].'</option>';
}
echo '</select>
</p>';
}
echo '<input type="submit" name="valider" value="Valider"/>';
</form>
if (isset($_POST['id'])) {
$sql="SELECT prenom, nom, adresse,ville from abonnes WHERE id= ".intval($_POST['id']);
$requete = mysql_query($sql);
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'];
}
} |