Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "test";
- $dbname = "test";
- // Create Connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- //check Connection
- if ($conn->connect_error) {
- die("Connection failed: ". $conn->connect_error);
- }
- $conn->close();
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Dropdown AJAX</title>
- </head>
- <body>
- <div class="city">
- <label>Stadt</label>
- <select name="city">
- <option value="">Wähle eine Stadt</option>
- <!-- populate using php -->
- <?php
- $query = "SELECT ort FROM test2";
- $result = mysqli_query($conn, $query);
- //loop
- foreach ($result as $city) {
- ?>
- <option value="<?php echo $city["ort"]; ?>"></option>
- <?php
- }
- ?>
- </select>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment