-
Notifications
You must be signed in to change notification settings - Fork 0
/
reservations.php
104 lines (86 loc) · 2.52 KB
/
reservations.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
<!DOCTYPE html>
<?php
require "menu.php";
require "connectToDB.php";
$ID = "";
$error = "";
if(isset($_GET['id']))
{
$ID = $_GET['id'];
if(is_numeric($ID))
{
$query = "DELETE FROM `reservation` WHERE `ReservationID` = $ID";
if (!mysqli_query($mysql_connection, $query)) {
$er = mysqli_error($mysql_connection);
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>$er<strong>.
</div>";
}
else
{
mysqli_close($mysql_connection);
header("Location:reservations.php");
}
}
else
{
$error = "<div class='alert alert-danger alert-dismissable fade in'>
<strong>Δεν υπάρχει κράτηση με αυτό το ID<strong>.
</div>";
}
}
?>
<html>
<body>
<div class="container">
<?php echo $error;?>
<a href="reservationAdd.php" class="btn btn-primary">Add Reservation</a>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Reservation ID</th>
<th>Customer SSN</th>
<th>Vehicle ID</th>
<th style="width:90px">Start Date</th>
<th style="width:90px">Finish date</th>
<th>Date of Reservation</th>
<th>Paid</th>
<th>Start Location</th>
<th>Finish Location</th>
<th>License Plate</th>
</tr>
</thead>
<?php
require 'connectToDB.php';
$query = "SELECT * FROM reservation";
if($query_run = mysqli_query($mysql_connection,$query))
{
while($row = mysqli_fetch_assoc($query_run))
{
$id = $row["ReservationID"];
$cssn = $row["SSN_cust"];
$vid = $row["VehicleID"];
$sdate = $row["StartDate"];
$fdate = $row["FinishDate"];
$rdate = $row["DateOfReserv"];
$paid = $row["Paid"];
$sloc = $row["StartLocation"];
$floc = $row["FinishLocation"];
$lplate = $row["LicensePlate"];
echo '<tr><td>'.$id.'</td><td>'.$cssn.'</td><td>'.$vid.'</td><td>'.$sdate.'</td><td>'.$fdate.'</td><td>'.$rdate.'</td><td>'.$paid.'</td><td>'.$sloc.'</td><td>'.$floc.'</td><td>'.$lplate.'</td>';
echo '<td><div class="btn-group btn-group-justified"><a class="btn btn-default" href="reservationUpdate.php?id='.$id.'">Edit</a>';
echo '<a class="btn btn-danger" href="reservations.php?id='.$id.'">Delete</a></dive></td></tr>';
}
}
else
{
echo 'Error';
}
mysqli_close($mysql_connection);
?>
</table>
</div>
</div>
</body>
</html>