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/sabrinaluxebraidedwigs.com/public_html/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("header.php"); ?>
<title><?php echo $company_name; ?> - Shop</title>
<div class="col-md-12 col-xs-12" id="product_msg"></div>
<!-- Title Page -->
<section class="bg-title-page p-t-40 p-b-50 flex-col-c-m" style="background-image: url(images/banner-min.jpg);">
<h2 class="l-text2 t-center">
<div class='space_top'></div>
Shop
</h2>
</section>
<!-- Content page -->
<section class="bgwhite p-t-55 p-b-65">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12 p-b-50">
<!-- -->
<!-- Product -->
<div class="row">
<?php $count=0;
$sql = "SELECT COUNT(product_id) FROM products WHERE in_stock='Yes'";
$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 = 40;
//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 products WHERE in_stock='Yes' $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>';
$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$previous&id=$cat_id\"> Prev </a>";
//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>';
$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$i&id=$cat_id\"> $i </a>";
}
}
}
//render target number bt not link
//$paginationCtrls .= ''.$pagenum.' ';
$paginationCtrls .= '<a href="#">'.$pagenum.'</a>';
//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>';
$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$i&id=$cat_id\"> $i </a>";
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>';
$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$next&id=$cat_id\"> Next </a>";
}
}
if(mysqli_num_rows($query) > 0){
while ($row_back_deals = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$product_id = $row_back_deals['product_id'];
$product_title = $row_back_deals['product_title'];
$product_price = $row_back_deals['product_price'];
$product_desc = $row_back_deals['product_desc'];
$product_image = $row_back_deals['product_image'];
$old_price = $row_back_deals['old_price'];
$product_cat = $row_back_deals['product_cat'];
$new = $row_back_deals['new'];
if($new == "Yes"){$new_tag = "block2-labelnew";}
else{$new_tag = "";}
//calculate the rating of each product
$stmt_reviews = $con -> prepare('SELECT rating FROM product_reviews WHERE product_id = ?');
$stmt_reviews -> bind_param('s',$product_id);
$stmt_reviews -> execute();
$stmt_reviews -> store_result();
$stmt_reviews -> bind_result($product_rating);
$numrows_reviews = $stmt_reviews -> num_rows();
if($numrows_reviews > 0){
$total_rating = array();
while ($stmt_reviews -> fetch()) {
array_push($total_rating,$product_rating);
}
$all_ratings = array_sum($total_rating);
$average_rating = $all_ratings / $numrows_reviews;
$rounded_up = round($average_rating);
$rating_display = " $rounded_up / 5";
}
else{$rating_display = "";$rounded_up = 0;}
$count++; ?>
<div class='col-sm-3 col-md-3 col-lg-3 p-b-50' data-aos='zoom-in' data-aos-delay='100'>
<?php include("product.php"); ?>
</div>
<?php
}
}
else{echo"Nothing found";}
?>
</div>
<!-- Pagination -->
<div class="col-12 text-center">
<ul class="pagination clearfix">
<?php
echo"$paginationCtrls<br/><br/><br/><br/>";
echo "<div class='text_line'>$textline2</div>";
?>
</ul>
</div>
</div>
</div>
</div>
</section>
<?php include("footer.php"); ?>