-
Notifications
You must be signed in to change notification settings - Fork 0
/
P_view.php
85 lines (77 loc) · 3.24 KB
/
P_view.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
<?php include_once 'P_header.php'; ?>
<?php
include 'dbh.inc.php';
$sql = "SELECT * FROM `hotel_reservation` WHERE `user_name` = '$Username' ORDER BY `Hotel_Res_ID` DESC";
$result = $conn->query($sql);
?>
<div class="row">
<table class="table">
<thead>
<tr>
<th>Reservation ID</th>
<th>Package Name</th>
<th>Hotel Name</th>
<th>Full Name</th>
<th>Email</th>
<th>Booking For</th>
<th>Room Type</th>
<th>No Of Adults</th>
<th>No Of Children</th>
<th>Check In time</th>
<th>Check Out time</th>
<th>Total Price</th>
<th>Special Request</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
// Fetch the package name based on the Package_ID
$packageID = $row['Package_ID'];
$packageQuery = "SELECT `Package_Name` FROM `hotel_package` WHERE `Package_ID` = '$packageID'";
$packageResult = $conn->query($packageQuery);
$packageName = '';
$HotelQuery = "SELECT `Hotel_Name` FROM `hotel` WHERE `Hotel_ID` = (SELECT `Hotel_ID` FROM `hotel_package` WHERE `Package_ID` = '$packageID')";
$HotelResult = $conn->query($HotelQuery);
$HotelName = '';
if ($packageResult->num_rows > 0) {
$packageRow = $packageResult->fetch_assoc();
$packageName = $packageRow['Package_Name'];
}
if ($HotelResult->num_rows > 0) {
$HotelRow = $HotelResult->fetch_assoc();
$HotelName = $HotelRow['Hotel_Name'];
}
?>
<tr>
<td><?php echo $row['Hotel_Res_ID']; ?></td>
<td><?php echo $packageName ?></td>
<td><?php echo $HotelName?></td>
<td><?php echo $row['Full_Name']; ?></td>
<td><?php echo $row['Email']; ?></td>
<td><?php echo $row['Booking_For']; ?></td>
<td><?php echo $row['Room_Type']; ?></td>
<td><?php echo $row['No_Of_Adult']; ?></td>
<td><?php echo $row['No_Of_Children']; ?></td>
<td><?php echo $row['Check_In_Date']; ?></td>
<td><?php echo $row['Check_Out_Date']; ?></td>
<td><?php echo $row['Total_Price']; ?></td>
<td><?php echo $row['Special_Request']; ?></td>
<td> <!-- action buttons -->
<div class = "buttonE">
<a href="P_edit.php?edit=<?php echo $row['Hotel_Res_ID']; ?>">Edit</a>
<a href="P_delete.php?delete=<?php echo $row['Hotel_Res_ID']; ?>" id = "del" onclick = "return deleteRes()">Delete</a>
</div>
</td>
</tr>
<?php
}
}
?>
</table>
<div class="add-new-button">
<a href="P_reserve.php">Add New +</a>
</div>
</div>
<?php include_once 'P_footer.php'; ?>