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/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("header.php"); ?>
<?php
if (isset($_GET['product'])){
$product_id = mysqli_real_escape_string($con,$_GET['product']);
$stmt = $con -> prepare('SELECT * FROM products WHERE product_id=?');
$stmt -> bind_param('s',$product_id);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($product_id,$product_cat,$product_brand,$product_title,$product_price,$product_desc,$product_image,$product_keywords,$old_price,$new_tag,$home_products,$tags,$in_stock,$featured,$picture2,$picture3,$picture4,$picture5,$picture6);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
//get category name
$get_categories = mysqli_query($con,"SELECT * FROM categories WHERE cat_id=$product_cat");
$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"];
}//end of while loop
}
}
}else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit();}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit();}
?>
<title><?php echo $company_name; ?> - <?php echo $product_title; ?></title>
<div class="col-md-12 col-xs-12" id="product_msg"></div>
<!-- Start All Title Box -->
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2><?php echo $product_title; ?></h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Shop</a></li>
<li class="breadcrumb-item active"><?php echo $product_title; ?> </li>
</ul>
</div>
</div>
</div>
</div>
<!-- End All Title Box -->
<!-- Start Shop Detail -->
<div class="shop-detail-box-main">
<div class="container">
<div class="row">
<div class="col-xl-5 col-lg-5 col-md-6">
<div id="carousel-example-1" class="single-product-slider carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block w-100" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $product_image; ?>">
</div>
<?php if($picture2 !== ""){ ?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture2; ?>" >
</div>
<?php } ?>
<?php if($picture3 !== ""){ ?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture3; ?>" >
</div>
<?php } ?>
<?php if($picture4 !== ""){ ?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture4; ?>" >
</div>
<?php } ?>
<?php if($picture5 !== ""){ ?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture5; ?>" >
</div>
<?php } ?>
<?php if($picture6 !== ""){ ?>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture6; ?>" >
</div>
<?php } ?>
</div>
<a class="carousel-control-prev" href="#carousel-example-1" role="button" data-slide="prev">
<i class="fa fa-angle-left" aria-hidden="true"></i>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-example-1" role="button" data-slide="next">
<i class="fa fa-angle-right" aria-hidden="true"></i>
<span class="sr-only">Next</span>
</a>
<ol class="carousel-indicators">
<li data-target="#carousel-example-1" data-slide-to="0" class="active">
<img class="d-block w-100 img-fluid" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $product_image; ?>" alt="" />
</li>
<?php if($picture2 !== ""){ ?>
<li data-target="#carousel-example-1" data-slide-to="1">
<img class="d-block w-100 img-fluid" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture2; ?>" alt="" />
</li>
<?php } ?>
<?php if($picture3 !== ""){ ?>
<li data-target="#carousel-example-1" data-slide-to="1">
<img class="d-block w-100 img-fluid" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture3; ?>" alt="" />
</li>
<?php } ?>
<?php if($picture4 !== ""){ ?>
<li data-target="#carousel-example-1" data-slide-to="1">
<img class="d-block w-100 img-fluid" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture4; ?>" alt="" />
</li>
<?php } ?>
<?php if($picture5 !== ""){ ?>
<li data-target="#carousel-example-1" data-slide-to="1">
<img class="d-block w-100 img-fluid" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture5; ?>" alt="" />
</li>
<?php if($picture6 !== ""){ ?>
<li data-target="#carousel-example-1" data-slide-to="1">
<img class="d-block w-100 img-fluid" src="<?php echo $admin_no; ?>/assets/img/products/<?php echo $picture6; ?>" alt="" />
</li>
<?php } ?>
<?php } ?>
</ol>
</div>
</div>
<div class="col-xl-7 col-lg-7 col-md-6">
<div class="single-product-details">
<h2><?php echo $product_title; ?></h2>
<h5><?php echo $currency; ?><?php echo number_format((float)$product_price, 2, '.', ','); ?></h5>
<p class="available-stock"><span><?php if($in_stock == "Yes"){echo "<span style='font-weight:900;color:forestgreen;'>In Stock</span>";}else{echo "<span style='font-weight:900;color:crimson;'>Out of Stock</span>";} ?></span><p>
<h4>Description:</h4>
<p><?php echo $product_desc; ?></p>
<div class="price-box-bar">
<div class="cart-and-bay-btn">
<?php if($user_id !==""){
//then this part is for likes
$get_likes = mysqli_query($con,"SELECT * FROM favs WHERE user_id='$user_id' AND product_id='$product_id'")or die(mysqli_error($con));
if(mysqli_num_rows($get_likes) == 0){
$fas_or_far = "far";
$icon_text = "Add to Wishlist";
}
else{
$fas_or_far = "fas";
$icon_text = "Remove from Wishlist";
} ?>
<a style='color:white;' class="btn hvr-hover heart<?php echo $product_id; ?>" title="<?php echo $icon_text; ?>" id="toggle_link">
<i class="<?php echo $fas_or_far; ?> fa-heart"></i> Add to wishlist</a>
<?php }else{ ?>
<a style='color:white;' href='sign_in.php' class="btn hvr-hover" title="Wishlist">
<i class="far fa-heart"></i> Add to wishlist</a>
<?php } ?>
<script>
jQuery(document).ready(function($){
$('.heart<?php echo"$product_id"; ?>').on('click',function() {
$(this).find("i").toggleClass("far fas selected-heart border-heart");
let title = $("#toggle_link").attr("title");
console.log(title);
if (title == "Add to Wishlist"){
$('#toggle_link'). attr("title", 'Remove from Wishlist');
}
if (title == "Remove from Wishlist"){
$('#toggle_link'). attr("title", 'Add to Wishlist');
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.open("GET", "update_fav.php?user_id=<?php echo"$user_id"; ?>&product_id=<?php echo"$product_id"; ?>", true);
xhttp.send();
});
});
</script>
<?php if($in_stock == "Yes") { ?>
<a class="btn hvr-hover" data-fancybox-close="" href="#" pid="<?php echo $product_id; ?>"id="product">Add to cart</a>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<div class="row my-5">
<div class="card card-outline-secondary my-4" style='width:100%;'>
<div class="card-header">
<h2>Product Reviews</h2>
</div>
<div class="card-body">
<?php
$stmt_re = $con -> prepare('SELECT * FROM product_reviews WHERE product_id = ? ORDER BY id DESC');
$stmt_re -> bind_param('s',$product_id);
$stmt_re -> execute();
$stmt_re -> store_result();
$stmt_re -> bind_result($review_id,$review_product_id,$review_user_id,$review,$rating,$review_date);
$numrows_re = $stmt_re -> num_rows();
if($numrows_re > 0){
while ($stmt_re -> fetch()) {
//format date
$date = new DateTime("$review_date");
$review_date_formatted = $date->format('jS M Y');
//get review first and last name
$stmt_na = $con -> prepare('SELECT first_name,last_name FROM users WHERE user_id = ?');
$stmt_na -> bind_param('s',$review_user_id);
$stmt_na -> execute();
$stmt_na -> store_result();
$stmt_na -> bind_result($reviewer_first_name,$reviewer_last_name);
$numrows_na = $stmt_na -> num_rows();
if($numrows_na > 0){
while ($stmt_na -> fetch()) { }}
?>
<div class="media mb-3 rate_container">
<div class="mr-2">
<?php include("rating.php"); ?>
</div>
<div class="media-body">
<p><?php echo $review; ?></p>
<small class="text-muted"><?php echo "$reviewer_first_name $reviewer_last_name - $review_date_formatted"; ?></small>
</div>
</div>
<hr>
<?php } }else{echo"<div>No reviews yet.</div>";} ?>
<a href="review.php?product=<?php echo $product_id; ?>" class="btn hvr-hover">Leave a Review</a>
</div>
</div>
</div>
<div class="row my-5">
<div class="col-lg-12">
<div class="title-all text-center">
<h1>Featured Products</h1>
<p>View these similar items</p>
</div>
<div class="featured-products-box owl-carousel owl-theme">
<?php
$yes="Yes";$eight = 8;
$stmt_caa = $con -> prepare('SELECT * FROM products WHERE product_cat = ? ORDER BY RAND() LIMIT ?');
$stmt_caa -> bind_param('si',$product_cat,$eight);
$stmt_caa -> execute();
$stmt_caa -> store_result();
$stmt_caa -> bind_result($product_idd,$product_catd,$product_brandd,$product_titled,$product_priced,$product_descd,$product_imaged,$product_keywordsd,$old_priced,$new_tagd,$home_productsd,$tagsd,$in_stockd,$featuredd,$picture2d,$picture3d,$picture4d,$picture5d,$picture6d);
$numrows_caa = $stmt_caa -> num_rows();
if($numrows_caa > 0){
while ($stmt_caa -> fetch()) {
if($product_idd !== $product_id){
//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 = " $rounded_up / 5";
}
else{$rating_display = "";$rounded_up = 0;}
?>
<div class="item">
<?php include("product_similar.php"); ?>
</div>
<?php } } }else{echo "No similar products found.";} ?>
</div>
</div>
</div>
</div>
</div>
<!-- End Cart -->
<?php include("ig_feed.php"); ?>
<?php include("footer.php"); ?>