-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproduct-details.php
143 lines (126 loc) · 4.95 KB
/
product-details.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
138
139
140
141
142
143
<?php
include 'config.php';
$id = isset($_GET['id']) ? intval($_GET['id']) : 1;
$query = new Database();
$product = $query->getById('products', $id);
if ($product) {
$category = isset($product['category_id']) ? $query->getById('category', $product['category_id'])['category_name'] : 'Unknown';
$product_images = $query->executeQuery("SELECT image_url FROM product_images WHERE product_id = $id")->fetch_all(MYSQLI_ASSOC);
$product_images = !empty($product_images) ? array_column($product_images, 'image_url') : [];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Product Details</title>
<link href="favicon.ico" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/aos/aos.css" rel="stylesheet">
<link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
<link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
<link href="assets/css/main.css" rel="stylesheet">
</head>
<style>
.product-not-found {
min-height: 30vh;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
background-color: #f8f9fa;
padding: 20px;
border-radius: 10px;
}
.product-not-found h3 {
font-size: 24px;
color: #dc3545;
margin-bottom: 10px;
}
.product-not-found p {
font-size: 18px;
color: #6c757d;
}
</style>
<body class="portfolio-details-page">
<?php include 'includes/header.php'; ?>
<main class="main">
<div class="page-title" data-aos="fade">
<div class="container">
<nav class="breadcrumbs">
<ol>
<li><a href="./">Home</a></li>
<li class="current">Product Details</li>
</ol>
</nav>
<h1>Product Details</h1>
</div>
</div>
<section id="portfolio-details" class="portfolio-details section">
<div class="container" data-aos="fade-up" data-aos-delay="100">
<div class="row gy-4">
<?php if ($product): ?>
<div class="col-lg-8">
<div class="portfolio-details-slider swiper init-swiper">
<script type="application/json" class="swiper-config">
{
"loop": true,
"speed": 600,
"autoplay": { "delay": 5000 },
"slidesPerView": "auto",
"pagination": { "el": ".swiper-pagination", "type": "bullets", "clickable": true }
}
</script>
<div class="swiper-wrapper align-items-center">
<?php foreach ($product_images as $image): ?>
<div class="swiper-slide">
<img src="assets/img/product/<?php echo $image; ?>" alt="Product Image">
</div>
<?php endforeach; ?>
</div>
<div class="swiper-pagination"></div>
</div>
</div>
<div class="col-lg-4">
<div class="portfolio-info" data-aos="fade-up" data-aos-delay="200">
<h3>Product Information</h3>
<ul>
<li><strong>Category</strong>: <?php echo $category; ?></li>
<li><strong>Product Name</strong>: <?php echo $product['product_name']; ?></li>
<li><strong>Price</strong>: <?php echo number_format($product['price'], 0, '', ' '); ?></li>
</ul>
</div>
<div class="portfolio-description" data-aos="fade-up" data-aos-delay="300">
<h2>Product Description</h2>
<p><?php echo $product['product_name']; ?> – <?php echo $product['description']; ?></p>
</div>
</div>
<?php else: ?>
<div class="col-12 product-not-found">
<div>
<h3>Product not found</h3>
<p>The product you are looking for does not exist.</p>
</div>
</div>
<?php endif; ?>
</div>
</div>
</section>
</main>
<?php include 'includes/footer.php'; ?>
<!-- Scroll to top -->
<a href="#" id="scroll-top" class="scroll-top d-flex align-items-center justify-content-center"><i
class="bi bi-arrow-up-short"></i></a>
<!-- Vendor JS Files -->
<script src="assets/vendor/aos/aos.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/glightbox/js/glightbox.min.js"></script>
<script src="assets/vendor/swiper/swiper-bundle.min.js"></script>
<!-- Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>