-
Notifications
You must be signed in to change notification settings - Fork 1
/
flights_api.php
53 lines (44 loc) · 1.08 KB
/
flights_api.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
$db_name = "id5038794_dbms_project";
$mysql_username = "id5038794_vishal";
$mysql_password = "#Vishal$1";
$server_name = "localhost";
$conn = mysqli_connect($server_name, $mysql_username, $mysql_password, $db_name);
$stmt = $conn->prepare("SELECT
airline,
flight_no,
sour,
(SELECT
airport_code
FROM
airport_codes
WHERE
place = sour) AS sourCode,
dest,
(SELECT
airport_code
FROM
airport_codes
WHERE
place = dest) AS destCode,
arr_time,
dept_time
FROM
flights;");
$stmt->execute();
$stmt->bind_result($airline, $flight_no, $sour, $sourCode ,$dest, $destCode, $arr_time, $dept_time);
$flights = array();
while($stmt->fetch()) {
$temp = array();
$temp['airline'] = $airline;
$temp['flight_no'] = $flight_no;
$temp['sour'] = $sour;
$temp['sourCode'] = $sourCode;
$temp['dest'] = $dest;
$temp['destCode'] = $destCode;
$temp['arr_time'] = $arr_time;
$temp['dept_time'] = $dept_time;
array_push($flights, $temp);
}
echo json_encode($flights);
?>