Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Connexion à la BDD
- $link = mysqli_connect('127.0.0.1', 'root', '', 'csiw');
- if (! $link) { // On vérifie si le lien à la BDD est fonctionnel
- die('Error : could not connect to database. ' . mysqli_connect_error());
- }
- $query = 'SELECT * FROM users'; // la requête pour récuperer le sinfos de la table
- ?>
- <!DOCTYPE html>
- <html lang="en" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title>Utilisateurs</title>
- </head>
- <body>
- <?php
- // Si le formulaire a été soumis
- if (isset($_GET['user'])) {
- // On affiche l'ID
- echo 'ID : ' . $_GET['user'];
- }
- ?>
- <form action="index.php" method="get">
- <?php if ($result = mysqli_query($link, $query) AND mysqli_num_rows($result) > 0) { ?>
- <select name="user" id="user">
- <?php
- while ($row = mysqli_fetch_row($result)) {
- echo '<option value="' . $row[0] . '">' .$row[1] . ' ' . $row[2] . '</option>';
- }
- ?>
- </select>
- <button type="submit">Soumettre</button>
- <?php
- } else {
- echo "Personne dans la BDD";
- }
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement