-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathquery.php
44 lines (33 loc) · 1.09 KB
/
query.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
<html>
<body>
<head>
<link rel="stylesheet" type="text/css" href="table.css">
</head>
<?php
$servername = "localhost";
$username = "root";
$password = "1234";
$dbname = "flight db";
$city = $_POST["city"];
// Create connection
$conn = new mysqli("localhost","root","1234","flight db");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = mysqli_query($conn, "CALL getFlightsByCity('$city');") or die("Query fail :" .mysqli_error());
?>
<table class="container"><tr><th>city</th><th>date</th><th>origin</th><th>airline</th><th>dep_time</th><th>destination</th></tr>
<?php if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["city"]. "</td><td>" . $row["d_date"]. "</td><td> " . $row["origin"]. "</td><td>" . $row["airline"]. "</td><td>" . $row["d_time"]."</td><td>" . $row["destination"] ."</td></tr>";
}
} else {
echo "0 results";
}
$conn->close();
?>
</table>
</body>
</html>