Source : lesson_09_d2_departements.php |
Résultat |
<?php //Connexion à la base de données require ("../mysql_connexion/mysql_connexion.php"); $action_file = "show_solutions.php?exercise=lesson_09_d2_departements.php"; if (!isset($_POST['departement_code'])) { echo "<table border=3 align=center > "; echo "<CAPTION align=top><p><h3> Trouvez un département </p>"; echo "<form action=$action_file method=post>"; echo "<tr><th>Code ou début du code du département</th></tr>"; echo "<tr><td><input type=text size= 3 name='departement_code'>"; echo "</td></tr>"; echo "<td height=30><input type=submit value='Envoyer'>"; echo "</table></body></html>"; } else { if ($_POST['departement_code'] > 0 && $_POST['departement_code'] < 96 ) { $code_dept = $_POST['departement_code']; echo "<br/><table border=2 align=center>"; echo "<tr><td>Le code choisi: </td><td>$code_dept</td></tr>"; $result = mysqli_query($mysqli,"select * from atelierphp_sol_departements_prefecture where departement_code like '$code_dept%' ") ; while ($row=mysqli_fetch_array($result)) { echo "<tr><td>".$row['departement_nom']."</td>"; echo "<td>".$row['departement_code']."</td></tr>"; } echo "<td colspan=2 align=center> <a href=$action_file>Un autre ?</a></tr>"; echo "</table>"; } else echo "Saisie invalide"; } ?>
|
|