-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_flights.php
113 lines (107 loc) · 3.53 KB
/
all_flights.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php include_once 'header.php'; ?>
<?php include_once 'footer.php';
require '../helpers/init_conn_db.php';?>
<?php
if(isset($_POST['del_flight']) and isset($_SESSION['adminId'])) {
$flight_id = $_POST['flight_id'];
$sql = 'DELETE FROM Flight WHERE flight_id=?';
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)) {
header('Location: ../index.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt,'i',$flight_id);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_close($conn);
// header('Location: all_flights.php');
echo("<script>location.href = 'all_flights.php';</script>");
exit();
}
}
?>
<style>
table {
background-color: white;
}
h1 {
margin-top: 20px;
margin-bottom: 20px;
font-family: 'product sans';
font-size: 45px !important;
font-weight: lighter;
}
a:hover {
text-decoration: none;
}
body {
/* background-color: #B0E2FF; */
background-color: #efefef;
}
th {
font-size: 22px;
/* font-weight: lighter; */
/* font-family: 'Courier New', Courier, monospace; */
}
td {
margin-top: 10px !important;
font-size: 16px;
font-weight: bold;
font-family: 'Assistant', sans-serif !important;
}
</style>
<main>
<?php if(isset($_SESSION['adminId'])) { ?>
<div class="container-md mt-2">
<h1 class="display-4 text-center text-secondary"
>FLIGHT LIST</h1>
<table class="table table-sm table-bordered">
<thead class="thead-dark">
<tr>
<th scope="col">ID</th>
<th scope="col">Arrival</th>
<th scope="col">Departure</th>
<th scope="col">Source</th>
<th scope="col">Destination</th>
<th scope="col">Airline</th>
<th scope="col">Seats</th>
<th scope="col">Price</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php
$sql = 'SELECT * FROM Flight ORDER BY flight_id DESC';
$stmt = mysqli_stmt_init($conn);
mysqli_stmt_prepare($stmt,$sql);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
echo "
<tr class='text-center'>
<td scope='row'>
<a href='pass_list.php?flight_id=".$row['flight_id']."'>
".$row['flight_id']." </a> </td>
<td>".$row['arrivale']."</td>
<td>".$row['departure']."</td>
<td>".$row['source']."</td>
<td>".$row['Destination']."</td>
<td>".$row['airline']."</td>
<td>".$row['Seats']."</td>
<td>$ ".$row['Price']."</td>
<td>
<form action='all_flights.php' method='post'>
<input name='flight_id' type='hidden' value=".$row['flight_id'].">
<button class='btn' type='submit' name='del_flight'>
<i class='text-danger fa fa-trash'></i></button>
</form>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
<?php } ?>
</main>