46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
include "../ConnectDB.php";
|
|
$destinationCity = $_REQUEST["destinationCity"];
|
|
$departureCity = $_REQUEST["departureCity"];
|
|
|
|
|
|
// Fetch flight information from the database that matches the departure and destination cities
|
|
$start=microtime(true);
|
|
$sql = "SELECT
|
|
transport_railway.train_id,
|
|
transport_railway.train_code,
|
|
departure_city.name AS from_name,
|
|
arrival_city.name AS dest_name,
|
|
transport_railway.start_time,
|
|
transport_railway.arrive_time,
|
|
transport_railway.week_routine
|
|
FROM
|
|
transport_railway
|
|
JOIN
|
|
transport_railway_station AS departure_station ON transport_railway.from_station_id = departure_station.station_id
|
|
JOIN
|
|
transport_railway_station AS arrival_station ON transport_railway.dest_station_id = arrival_station.station_id
|
|
JOIN
|
|
cities AS departure_city ON departure_station.city_id = departure_city.id
|
|
JOIN
|
|
cities AS arrival_city ON arrival_station.city_id = arrival_city.id
|
|
WHERE arrival_city.name LIKE '%".$destinationCity."%' AND departure_city.id='".$departureCity."'";
|
|
$result = $conn->query($sql);
|
|
$end = microtime(true);
|
|
$execution_time = $end - $start;
|
|
$data = array();
|
|
if ($result->num_rows > 0) {
|
|
while($row = $result->fetch_assoc()) {
|
|
$data[] = $row;
|
|
}
|
|
} else {
|
|
$data[] = "No result";
|
|
}
|
|
|
|
echo json_encode(array("data" => $data,"time"=>$execution_time));
|
|
?>
|
|
|
|
|
|
|
|
|