-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistings.php
More file actions
269 lines (238 loc) · 13.5 KB
/
Copy pathlistings.php
File metadata and controls
269 lines (238 loc) · 13.5 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?php
session_start(); // Essential for the cart functionality to work
$conn = mysqli_connect("localhost", "root", "", "clothingstore_db");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Handle Search and Filtering - Crucial Update: Constraint enforces only 'approved' items visibility
$where = " WHERE status = 'approved'";
if (isset($_GET['search']) && !empty($_GET['search'])) {
$search = mysqli_real_escape_string($conn, $_GET['search']);
$where .= " AND product_name LIKE '%$search%'";
}
if (isset($_GET['cat']) && !empty($_GET['cat'])) {
$cat = mysqli_real_escape_string($conn, $_GET['cat']);
$where .= " AND category = '$cat'";
}
$query = "SELECT * FROM products $where ORDER BY id DESC";
$result = mysqli_query($conn, $query);
if (!$result) {
die("Query Error: " . mysqli_error($conn));
}
$count = mysqli_num_rows($result);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shop All Products | PASTIMES®</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
:root {
--primary-blue: #0678eb;
}
body { font-family: 'Inter', sans-serif; background-color: #fff; }
/* --- NAVIGATION --- */
.navbar { background: #fff; border-bottom: 1px solid #eee; padding: 15px 0; }
.navbar-brand { font-weight: 800; font-size: 24px; color: #000 !important; letter-spacing: 1px; }
.nav-link { color: #111 !important; font-weight: 600; font-size: 14px; margin: 0 12px; text-transform: uppercase; }
.nav-link.active { color: var(--primary-blue) !important; }
.btn-signup {
background: #0678eb;
color: #fff !important;
padding: 8px 22px;
border-radius: 0px;
font-weight: 600;
text-transform: uppercase;
font-size: 12px;
border: 1px solid #0678eb;
transition: all 0.3s ease;
}
.btn-signup:hover {
background: #000 !important;
color: #fff !important;
border-color: #000;
}
/* Logout Link Style */
.logout-link {
font-size: 11px;
text-transform: uppercase;
font-weight: 700;
color: #ff4d4d !important;
text-decoration: none;
}
/* Shop Banner */
.shop-banner {
background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://images.unsplash.com/photo-1441986300917-64674bd600d8?q=80&w=2070');
height: 350px; background-size: cover; background-position: center;
display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; text-align: center;
}
.shop-banner h1 { font-size: 52px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; }
.shop-banner p { font-size: 18px; color: #ddd; }
/* Filter Bar */
.filter-section { border-bottom: 1px solid #eee; padding: 30px 0; background: #fff; }
.cat-btn { border: 1px solid #ddd; background: none; padding: 10px 22px; border-radius: 0px; font-weight: 600; transition: 0.3s; margin-right: 10px; text-decoration: none; color: #333; display: inline-block; text-transform: uppercase; font-size: 12px; }
.cat-btn:hover, .cat-btn.active { background: #0678eb; color: white; border-color: #fff; }
/* Search */
.search-container { position: relative; }
.search-container i { position: absolute; left: 15px; top: 15px; color: #aaa; }
.search-container input { padding-left: 45px; border-radius: 0px; border: 1px solid #ddd; height: 45px; }
/* Product Grid */
.product-card { border: none; margin-bottom: 40px; transition: 0.3s; }
.product-card:hover { transform: translateY(-5px); }
.product-card img { border-radius: 0px; height: 400px; object-fit: cover; width: 100%; background: #f9f9f9; }
.badge-status { position: absolute; top: 15px; left: 15px; background: #000; color: #fff; padding: 5px 12px; font-weight: 700; font-size: 10px; text-transform: uppercase; }
.product-info { padding: 20px 0; }
.product-title { font-weight: 700; font-size: 18px; margin-bottom: 5px; text-transform: uppercase; }
.product-price { font-weight: 800; font-size: 20px; color: #333; }
.stock-info { font-size: 12px; color: #888; margin-bottom: 15px; }
.qty-input { width: 60px; height: 45px; text-align: center; border: 1px solid #ddd; border-radius: 0px; }
.btn-add-cart { background: var(--primary-blue); color: white; border: none; height: 45px; flex-grow: 1; font-weight: 700; text-transform: uppercase; font-size: 12px; }
.btn-add-cart:hover { background: var(--primary-blue); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
/* --- FOOTER --- */
footer { background-color: #000; padding: 40px 0; color: #fff; border-top: 1px solid #222; }
footer h5 { letter-spacing: 4px; font-weight: 800; text-transform: uppercase; }
.social-icons a { color: #fff; font-size: 22px; margin: 0 15px; transition: 0.3s; text-decoration: none; }
.social-icons a:hover { color: var(--primary-blue); }
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg sticky-top">
<div class="container">
<a class="navbar-brand" href="index.php">
Pastimes<i class="fa-solid fa-registered" style="font-size: 10px; vertical-align: top;"></i>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mx-auto">
<li class="nav-item"><a class="nav-link" href="index.php">Home</a></li>
<li class="nav-item"><a class="nav-link active" href="listings.php">Shop</a></li>
<li class="nav-item"><a class="nav-link" href="about.php">About</a></li>
<li class="nav-item"><a class="nav-link" href="catalogue.php">Gallery</a></li>
<li class="nav-item"><a class="nav-link" href="contact.php">Contact</a></li>
</ul>
<div class="d-flex align-items-center gap-3">
<a href="cart.php" class="text-dark position-relative">
<i class="fa-solid fa-bag-shopping fs-5"></i>
<?php if(isset($_SESSION['cart']) && count($_SESSION['cart']) > 0): ?>
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger" style="font-size: 10px;">
<?php echo count($_SESSION['cart']); ?>
</span>
<?php endif; ?>
</a>
<?php if(isset($_SESSION['user_id'])): ?>
<span class="small fw-bold text-uppercase" style="font-size: 11px;">
Hi, <?php echo explode(' ', $_SESSION['full_name'])[0]; ?>
</span>
<a href="logout.php" class="logout-link">Logout</a>
<?php else: ?>
<a href="authenticate.php" class="text-dark text-decoration-none small fw-bold text-uppercase">Sign In</a>
<a href="sign-up.php" class="btn btn-signup">Sign Up</a>
<?php endif; ?>
</div>
</div>
</div>
</nav>
<section class="shop-banner">
<div class="container">
<h1>Studio Collection</h1>
<p>Premium oversized essentials crafted in Midrand, GP.</p>
</div>
</section>
<section class="filter-section">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-7 mb-3 mb-lg-0">
<a href="listings.php" class="cat-btn <?php echo !isset($_GET['cat']) ? 'active' : ''; ?>">All</a>
<a href="listings.php?cat=T-Shirts" class="cat-btn <?php echo (isset($_GET['cat']) && $_GET['cat'] == 'T-Shirts') ? 'active' : ''; ?>">T-Shirts</a>
<a href="listings.php?cat=Hoodies" class="cat-btn <?php echo (isset($_GET['cat']) && $_GET['cat'] == 'Hoodies') ? 'active' : ''; ?>">Hoodies</a>
<a href="listings.php?cat=Bottoms" class="cat-btn <?php echo (isset($_GET['cat']) && $_GET['cat'] == 'Bottoms') ? 'active' : ''; ?>">Bottoms</a>
<a href="listings.php?cat=Outerwear" class="cat-btn <?php echo (isset($_GET['cat']) && $_GET['cat'] == 'Outerwear') ? 'active' : ''; ?>">Outerwear</a>
</div>
<div class="col-lg-5">
<form action="listings.php" method="GET" class="search-container">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="text" name="search" class="form-control" placeholder="Search Pastimes..." value="<?php echo isset($_GET['search']) ? htmlspecialchars($_GET['search']) : ''; ?>">
</form>
</div>
</div>
<div class="mt-4 text-center text-muted small">
<i class="fa-solid fa-boxes-stacked me-2"></i> Showing <?php echo $count; ?> products in Midrand
</div>
</div>
</section>
<section class="container my-5">
<div class="row">
<?php if($count > 0): ?>
<?php while($row = mysqli_fetch_assoc($result)): ?>
<div class="col-md-4">
<div class="product-card">
<div class="position-relative">
<span class="badge-status">
<?php echo !empty($row['brand']) ? htmlspecialchars($row['brand']) : 'Studio Select'; ?>
</span>
<img src="<?php echo htmlspecialchars($row['image_path']); ?>" alt="<?php echo htmlspecialchars($row['product_name']); ?>" onerror="this.src='https://via.placeholder.com/500x700?text=Pastimes'">
</div>
<div class="product-info">
<h5 class="product-title"><?php echo htmlspecialchars($row['product_name']); ?></h5>
<p class="product-price">R <?php echo number_format($row['price'], 2); ?></p>
<?php if(!empty($row['admin_note'])): ?>
<div class="p-2 mb-2 bg-light text-dark border-start border-primary" style="font-size:11px;">
<strong>Condition Note:</strong> <?php echo htmlspecialchars($row['admin_note']); ?>
</div>
<?php endif; ?>
<div class="stock-info">
<i class="fa-solid fa-circle-check me-1" style="color: #2ecc71;"></i> In Stock & Ready for Delivery
</div>
<form action="cart.php" method="POST" class="d-flex align-items-center mt-3">
<input type="hidden" name="product_id" value="<?php echo $row['id']; ?>">
<input type="number" name="quantity" value="1" min="1" class="qty-input me-2">
<button type="submit" class="btn btn-add-cart">
<i class="fa-solid fa-cart-shopping me-2"></i> Add to Cart
</button>
</form>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<div class="col-12 text-center py-5">
<h3 class="fw-bold">No pieces found.</h3>
<p class="text-muted">Try adjusting your search or category filters.</p>
<a href="listings.php" class="btn btn-dark px-4 mt-2">Clear All</a>
</div>
<?php endif; ?>
</div>
</section>
<footer>
<div class="container text-center">
<h5 class="mt-3 mb-1" style="letter-spacing: 2px;">PASTIMES</h5>
<p class="small mb-2" style="color: #bbb; font-size: 11px;">
© 2026 Pastimes® Collective. <br>
Headquartered in Midrand, South Africa.
</p>
<div class="social-icons mb-3">
<a href="#" style="margin: 0 10px;"><i class="fab fa-instagram"></i></a>
<a href="#" style="margin: 0 10px;"><i class="fab fa-tiktok"></i></a>
<a href="#" style="margin: 0 10px;"><i class="fab fa-facebook-f"></i></a>
</div>
<div class="pt-3" style="border-top: 1px solid #333; max-width: 340px; margin: 0 auto;">
<p class="mb-1" style="font-size: 9px; text-transform: uppercase; letter-spacing: 2px; color: #aaa;">
Digital Architecture & Direction
</p>
<p class="mb-0">
<a href="#" class="text-white text-decoration-none fw-bold" style="letter-spacing: 4px; font-size: 12px;">
Amo Matlhaga & Kea Masole
</a>
</p>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>