-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdescending.php
137 lines (128 loc) · 3.98 KB
/
descending.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
session_start();
if(session_id()=='' || isset($_SESSION['user'])){
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "1234";
$dbname = "coffeecorner";
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$sql = "SELECT * FROM add_reservation ORDER BY date DESC";
$result = mysqli_query($connection, $sql);
if(!$result)
{
die("database query fail!" . mysqli_error($connection) . mysqli_errno($connection));
}
if(isset($_POST['submit']))
{
$selected_val = $_POST['sort']; // Storing Selected Value In Variable
echo "You have selected :" .$selected_val;
if($selected_val=="ASC")
{
header("location: ascending.php");
}
else if($selected_val=="DESC")
{
header("location: descending.php");
}
}
?>
<!doctype html>
<html>
<head>
<link href="descending.css?v={random number/string}" rel="stylesheet" type="text/css">
<meta charset="utf-8">
<title>Admin | View Reservation</title>
</head>
<body class="ggwp">
<h2 class="h2">Coffee Corner</h2>
<nav class="navbar">
<ul class="ul">
<li class="dashboard"><a class="dashboard2" href="admin.php">Dashboard</a></li>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Notification</button>
<div id="myDropdown" class="dropdown-content">
<a href="notification.php">Add Notification</a>
<a href="notification1.php">View Notification</a>
</div>
</div>
<li class="view"><a class="view2" href="admin_view.php">View Reservation</a></li>
<li class="update"><a class="update2" href="reservation_status.php">Reservation Status</a></li>
<li class="delete"><a class="a_delete" href="admin_delete.php">Delete Reservation</a></li>
<li class="border-bottom"><a></a></li>
</ul>
</nav>
<p class="credential">Logged in as : <?php echo $_SESSION['user']; ?></p>
<a class="button_logout" href="admin_logout.php" name="logout">Log out</a>
<div class=details_box>
<h2>Customer Reservation</h2>
<section class="gg">
<form action="" method="post">
<select name="sort">
<option value="ASC">Ascending</option>
<option value="DESC">Descending</option>
</select>
<input type="submit" name="submit" value="SORT BY DATE">
</form>
</section>
<?php
// table reservation details
echo "<table width=\"1200\" border=\"1\" cellspacing=\"0px\" cellpadding=\"50px\">";
echo "<tr>";
echo "<th>Username</th>";
echo "<th>Reservation ID</th>";
echo "<th>Total Person</th>";
echo "<th>Date</th>";
echo "<th>Time</th>";
echo "<th>Status</th>";
echo "</tr>";
echo "<tr>";
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><?php echo $row['username']; ?></td>
<td><?php echo $row['reserve_id']; ?></td>
<td contenteditable="false"><?php echo $row['no_of_people']; ?></td>
<td><?php echo date('d/m/Y', strtotime($row['date'])); ?></td>
<td><?php echo date('h:i a', strtotime($row['time'])); ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php
}
}else{
echo "<script type='text/javascript'>alert('No reservation to be displayed. No customer yet!'); window.location.href = \"admin.php\";</script>";
}
echo "</tr>";
echo "</table>";
// end table reservation details
?>
</div>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
</script>
</body>
<?php
}
else
{
header("location: admin_login.php");
}
?>
</html>