-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateTimes.php
92 lines (77 loc) · 2.73 KB
/
updateTimes.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
<!--
Part 4:
Allow the user to update the actual departure tiem of a flight.
The user should choose from a list of flight codes, enter a new
time & the information in the table should be updated.
-->
<?php
include 'components/head.php';
?>
<body>
<div id="content">
<?php
include 'connectdb.php';
include 'components/navigation.php';
if (isset($_POST["flight"])) {
echo '<h2>Update another departure time?</h2>';
} else {
echo '<h2>Update departure time</h2>';
}
?>
<div class="main-content">
<form action="updateTimes.php" method="post">
<div class="form-group">
<label for="flight">Select Flight:</label>
<select name="flight">
<?php
$flights = $flights = $connection->query("select * from flight");
while ($row = $flights->fetch()) {
echo "<option value='".$row["Number"].$row["AirlineCode"]."'>".$row["Number"].$row["AirlineCode"]."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label for="departureHour">Hour:</label>
<select name="departureHour">
<?php
for ($i = 0; $i < 24; $i++) {
echo "<option value='".$i."'>".$i."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label for="departureMinute">Minute:</label>
<select name="departureMinute">
<?php
for ($i = 0; $i < 60; $i++) {
echo "<option value='".$i."'>".$i."</option>";
}
?>
</select>
</div>
<div class="form-group">
<input class="button" id="updateTimes_results" type="submit" value="Update Flight Times">
</div>
</form>
</div>
<div class="output-content">
<?php
if (isset($_POST["flight"])) {
$flightNumber = substr($_POST["flight"], 0, 3);
$airlineCode = "'".substr($_POST["flight"], 3)."'";
$departureTime = "'".$_POST["departureHour"].":".$_POST["departureMinute"].":00'";
$updateDeparture = "UPDATE flight SET ADepartTime=".$departureTime."WHERE Number=".$flightNumber." and AirlineCode=".$airlineCode;
$connection->exec($updateDeparture);
include 'components/flightInfo.php';
}
// include 'components/footer.php';
?>
</div>
</div>
</body>
<?php
include 'components/footer.php';
?>
</html>