Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "root";
- $dbname = "ont";
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $query = "SELECT nom FROM `equipement`";
- $result1 = mysqli_query($conn, $query);
- $options = "";
- while($row1 = mysqli_fetch_array($result1))
- {
- echo $options;
- $options = $options."<option>$row1[0]</option>";
- }
- function ajout()
- {
- $sqlimage = "SELECT image FROM equipement";
- $imageresult1 = mysqli_query($conn,$sqlimage);
- while($rows=mysqli_fetch_assoc($imageresult1))
- {
- $image = $rows['image'];
- echo "<img src='$image' >";
- echo "<br>";
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title> PHP SELECT OPTIONS FROM DATABASE </title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body>
- <select>
- <?php echo $options;?>
- </select>
- <form>
- <input type="submit" Onsubmit="ajout()">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement