1<!DOCTYPE html>
2<html>
3<head>
4 <title>PHP Retrieve Data from MySQL using Drop Down Menu</title>
5</head>
6<body>
7
8<form>
9 City:
10 <select>
11 <option disabled selected>-- Select City --</option>
12 <?php
13 include "dbConn.php"; // Using database connection file here
14 $records = mysqli_query($db, "SELECT city_name From tblcity"); // Use select query here
15
16 while($data = mysqli_fetch_array($records))
17 {
18 echo "<option value='". $data['city_name'] ."'>" .$data['city_name'] ."</option>"; // displaying data in option menu
19 }
20 ?>
21 </select>
22</form>
23
24<?php mysqli_close($db); // close connection ?>
25
26</body>
27</html>
28