Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/domains/ellexsleevesapartments.com/public_html/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
$page_title = "Your Reservations";
$page_header = "df4d5a9879.jpg";
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?> - <?php echo $page_title; ?></title>
<?php include("page_header.php"); ?>
<style>
table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
font-size:17px;
}
th, td {
text-align: left;
padding: 8px 28px 8px 28px;
}
tr:nth-child(even){background-color: #f2f2f2}
</style>
<section class="gallery-one gallery-one--page">
<div class="container">
<div class="row gx-5 align-items-center">
<?php $count=0;
$sql = "SELECT COUNT(id) FROM reservations WHERE email='$email' ORDER BY id DESC";
$query = mysqli_query($con, $sql);
$row = mysqli_fetch_row($query);
//here we have the total row count
$rows = $row[0];
//number of results we want per page
$page_rows = 400;
//tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure last cannot be less than 1
if($last < 1){$last = 1;}
//establish the page num variable
$pagenum = 1;
//Get pageum from $GET if it is present, else its 1
if(isset($_GET['pn'])){
$pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']);
}
//below 1 or more than last page
if($pagenum < 1){
$pagenum = 1;
}else if ($pagenum > $last) {
$pagenum = $last;
}
//this sets the range of rows to query for the chosen pagenum
$limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//grabs one page worth of rows
$sql = "SELECT * FROM reservations WHERE email='$email' ORDER BY id DESC $limit ";
$query = mysqli_query($con, $sql);
//this shows the user what page they on and total number
$textline1 = "Messages $rows";
$textline2 = "Page $pagenum of $last";
//establish the pagination controls
$paginationCtrls = "";
//if there is more than one page worth of results
if($last != 1){
if($pagenum > 1){
$previous = $pagenum - 1;
//$paginationCtrls .='<a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Previous</a>  ';
$paginationCtrls .='<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Prev</a></li>';
//render clickable links to the left of target page number
for($i = $pagenum-4; $i < $pagenum; $i++){
if($i > 0){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'"></a> ';
$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
}
}
}
//render target number bt not link
//$paginationCtrls .= ''.$pagenum.' ';
$paginationCtrls .= '<span class="pagination"><ul><li class="active"><a href="#">'.$pagenum.'</a></li></ul></span>';
//render clickable number links to the right of target number
for($i = $pagenum+1; $i <= $last; $i++){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> ';
$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
if($i >= $pagenum+4){
break;
}
}
//this does the same as above, only checking if we are on the last page
if($pagenum != $last) {
$next = $pagenum + 1;
$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$next.'">Next</a></li>';
}
}
if(mysqli_num_rows($query) > 0){
echo"
<div style='overflow-x:auto;'>
<table>
<tr>
<th>No</th>
<th>Room</th>
<th>Check in</th>
<th>Check out</th>
<th>Price</th>
<th>Date</th>
<th>Approved</th>
</tr>
";
while ($row_back_deals = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$reservation_id = $row_back_deals['reservation_id'];
$room = $row_back_deals['room'];
$check_in_raw = $row_back_deals['check_in'];
$check_out_raw = $row_back_deals['check_out'];
$precise_date = $row_back_deals['date'];
$approved = $row_back_deals['approved'];
$amount = $row_back_deals['amount'];
if($approved == "Approved"){$c = "forestgreen";}
if($approved == "No"){$c = "crimson";}
if($approved == "Pending"){$c = "royalblue";}
$check_in_formatted1=date_create("$check_in_raw");
$check_in_format = date_format($check_in_formatted1,"D,dS M, Y");
$check_out_formatted1=date_create("$check_out_raw");
$check_out_format = date_format($check_out_formatted1,"D,dS M, Y");
$precise_date_formatted1=date_create("$precise_date");
$precise_date_formatted = date_format($precise_date_formatted1,"D,dS M, Y");
$count++;
$stmt = $con -> prepare('SELECT header FROM rooms WHERE id=?');
$stmt -> bind_param('s',$room);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($room_name);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) { }
}
echo"
<tr>
<td>$count</td>
<td>$room_name</td>
<td>$check_in_format</td>
<td>$check_out_format</td>
<td>$currency";echo number_format((float)$amount, 2, '.', ',');echo"</td>
<td>$precise_date_formatted</td>
<td style='color:$c;'>$approved</td>
</tr>
";
}
echo"</table></div>";
}
else{echo"Nothing found";}
?>
</div>
<div class="row">
<div class="col-md-12">
<ul class="pagination clearfix">
<?php
echo"$paginationCtrls<br/><br/>";
echo "<div class='text_line'>$textline2</div>";
?>
</ul>
</div>
</div>
</div>
</section>
<?php include("footer.php"); ?>