Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "root";
  5. $dbname = "ont";
  6. $conn = new mysqli($servername, $username, $password, $dbname);
  7. // Check connection
  8. if ($conn->connect_error) {
  9. die("Connection failed: " . $conn->connect_error);
  10. }
  11. $query = "SELECT nom FROM `equipement`";
  12. $result1 = mysqli_query($conn, $query);
  13. $options = "";
  14. while($row1 = mysqli_fetch_array($result1))
  15. {
  16. echo $options;
  17. $options = $options."<option>$row1[0]</option>";
  18. }
  19. function ajout()
  20. {
  21. $sqlimage = "SELECT image FROM equipement";
  22. $imageresult1 = mysqli_query($conn,$sqlimage);
  23. while($rows=mysqli_fetch_assoc($imageresult1))
  24. {
  25. $image = $rows['image'];
  26. echo "<img src='$image' >";
  27. echo "<br>";
  28. }
  29. }
  30. ?>
  31.  
  32. <!DOCTYPE html>
  33.  
  34. <html>
  35. <head>
  36. <title> PHP SELECT OPTIONS FROM DATABASE </title>
  37. <meta charset="UTF-8">
  38. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  39. </head>
  40. <body>
  41. <select>
  42. <?php echo $options;?>
  43. </select>
  44. <form>
  45. <input type="submit" Onsubmit="ajout()">
  46. </form>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement