-
Notifications
You must be signed in to change notification settings - Fork 1
/
flights_search.php
57 lines (48 loc) · 1.21 KB
/
flights_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
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
54
55
56
57
<?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);
$clickeditem = $_GET['clickeditem'];
$clickeditem2 = $_GET['clickeditem2'];
$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
WHERE sour = $clickeditem
and dest = $clickeditem2;");
$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);
?>