-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
27 lines (22 loc) · 859 Bytes
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/* $connection = mysqli_connect("localhost","username","password","employee") or die("Error " . mysqli_error($connection));
//fetch department names from the department table
$sql = "select department_name from department";
$result = mysqli_query($connection, $sql) or die("Error " . mysqli_error($connection));
*/
$con = new PDO("mysql:host=localhost; dbname=projectinclude",
"root","root");
$con->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
$query = "SELECT DISTINCT city from airports";
$ps = $con->prepare($query);
// Fetch matching row.
$ps->execute();
$data = $ps->fetchAll(PDO::FETCH_ASSOC);
$dname_list = array();
foreach($data as $row)
{
$dname_list[] = $row['city'];
}
echo json_encode($dname_list);
?>