Advertisement
MizunoBrasil

Dropdown buscando campos no banco de dados

Dec 4th, 2022
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.     $link=mysqli_connect("localhost","root","");
  3.     mysqli_select_db($link,"dropdown");
  4. ?>
  5.  
  6. <!DOCTYPE html>
  7. <html lang="pt-br">
  8. <head>
  9.     <meta charset="UTF-8">
  10.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  11.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12.     <title>Document</title>
  13. </head>
  14. <body>
  15.     <h1>Dropdown buscando campos no banco de dados</h1>
  16.     <form name="form1" action="" method="post">
  17.         <select>
  18.         <?php
  19.                     //include ("conexao.php");
  20.             $res=mysqli_query($link,"select * from table1 order by name asc");
  21.             while ($row=mysqli_fetch_array($res))
  22.             {
  23.              ?>
  24.             <option><?php echo $row["name"]; ?></option>
  25.              <?php
  26.                 # code...
  27.            }
  28.             ?>            
  29.         </select>
  30.     </form>
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement