-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshop.php
272 lines (192 loc) · 10.5 KB
/
shop.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
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
270
271
272
<?php
session_set_cookie_params('86400');
session_start();
include("includes/db.php");
include("functions/functions.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lalla | Cửa hàng</title>
<!--css files-->
<link rel="stylesheet" href="css/shop.css">
<link rel="shortcut icon" href="assets/favicon.ico">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-137426789-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-137426789-2');
</script>
</head>
<body>
<!--Navigation-->
<?php
include 'nav.php';
?>
<!--end Navigation-->
<!--Content-->
<div class="wrapper">
<div class="content">
<section class="left">
<div class="control">
<div class="control__title">Danh Mục Sản Phẩm</div>
<div class="control__links">
<?php
$get_product_category = "select * from product_categories";
$run_product_category = mysqli_query($conn, $get_product_category);
while($row_product_category = mysqli_fetch_array($run_product_category)) {
$product_category_id = $row_product_category['product_category_id'];
$product_category_title = $row_product_category['product_category_title'];
echo "
<a class='control__link' href='shop.php?product_category=$product_category_id'>$product_category_title</a>
";
}
?>
</div>
</div>
<div class="control category">
<div class="control__title">Thể loại</div>
<div class="control__links">
<?php
$get_category = "select * from categories";
$run_category = mysqli_query($conn, $get_category);
while($row_category = mysqli_fetch_array($run_category)) {
$category_id = $row_category['category_id'];
$category_title = $row_category['category_title'];
echo "
<a class='control__link' href='shop.php?category=$category_id'>$category_title</a>
";
}
?>
</div>
</div>
</section>
<!--Products-->
<section class="contentProducts">
<div class="contentProducts__wrapper">
<div class="contentProducts__heading">
<h3 class="contentProducts__title anime">Sản phẩm mới</h3>
</div>
<div class="contentProducts__cards">
<!-- php get product -->
<?php
if (!isset($_GET['product_category'])) {
if (!isset($_GET['category'])) {
$per_page = 8;
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$start_from = ($page-1) * $per_page;
$get_products = "select * from products order by 1 DESC LIMIT $start_from, $per_page";
$run_products = mysqli_query($conn, $get_products);
while ($row_products = mysqli_fetch_array($run_products)) {
$product_id = $row_products['product_id'];
$product_title = $row_products['product_title'];
$product_price = $row_products['product_price'];
$product_price_format = number_format($product_price, 0, ',', '.');
$product_image_1 = $row_products['product_image_1'];
$product_label = $row_products['product_label'];
$product_sale = $row_products['product_sale'];
$product_sale_format = number_format((float)$product_sale, 0, ',', '.');
if ($product_label == 'new') {
$label = "<div class='contentProducts__label new'>mới</div>";
} else {
$label = "<div class='contentProducts__label'>giảm giá</div>";
}
if ($product_label == 'sale') {
$price = "
<div class='contentProducts__priceFinal'>$product_sale_format ₫</div>
<div class='contentProducts__priceOriginal'>$product_price_format ₫</div>
";
} else {
$price = "<div class='contentProducts__priceFinal'>$product_price_format ₫</div>";
}
echo "
<a class='contentProducts__card anime' href='details.php?product_id=$product_id'>
$label
<figure class='contentProducts__image'>
<img src='admin/$product_image_1' alt=''>
</figure>
<div class='contentProducts__text'>
<h4 class='contentProducts__productTitle'>$product_title</h4>
<div class='contentProducts__priceContainer'>
$price
</div>
<div class='contentProducts__info'>
<p class='contentProducts__link'><span>chi tiết</span><svg xmlns='http://www.w3.org/2000/svg' class='icon icon-tabler icon-tabler-circle-plus' width='44' height='44' viewBox='0 0 24 24' stroke-width='1.5' stroke='#7E56C8' fill='none' stroke-linecap='round' stroke-linejoin='round'>
<path stroke='none' d='M0 0h24v24H0z'/>
<circle cx='12' cy='12' r='9' />
<line x1='9' y1='12' x2='15' y2='12' />
<line x1='12' y1='9' x2='12' y2='15' />
</svg>
</p>
<div class='contentProducts__view cta cta02'><span>Xem</span></div>
</div>
</div>
</a>
";
}
?>
<?php
}
}
?>
<!-- end php get product -->
<?php get_p_category() ?>
<?php get_category() ?>
<!--end Card-->
</div>
<div class="pagination">
<?php
if (!isset($_GET['product_category'])) {
if (!isset($_GET['category'])) {
$get_products = "select * from products";
$run_products = mysqli_query($conn, $get_products);
$total_records = mysqli_num_rows($run_products);
$total_pages = ceil($total_records / $per_page);
echo "<a class='pagination__link first' href='shop.php?page=1'><img src='assets/icon-back.svg' alt=''></a>";
for ($i=1; $i<= $total_pages; $i++) {
echo "<a class='pagination__link' href='shop.php?page=$i'><span>$i</span></a>";
}
echo "<a class='pagination__link last' href='shop.php?page=$total_pages'><img src='assets/icon-next.svg' alt=''></a>";
}
}
?>
</div>
</div>
</section>
<!--end Products-->
</div>
<!--Footer-->
<footer class="footer">
<p class="footer__text">A project made by <a href="https://github.com/Conan286" target="_blank"
rel="noopener" class="link">Huy</a></p>
<div class="footer__icons">
<a href="#" target="_blank" rel="noopener" class="footer__icon linkedin"><span></span>
<p>Linkedin</p>
</a>
<a href="#" target="_blank" rel="noopener" class="footer__icon dribbble"><span></span>
<p>Dribbble</p>
</a>
<a href="#" target="_blank" rel="noopener" class="footer__icon codepen"><span></span>
<p>Codepen</p>
</a>
</div>
</footer>
<!--end Footer-->
</div>
<!--Script Files-->
<!--General-->
<script src="js/main.js"></script>
<script src="js/shop.js"></script>
<!--end Script Files-->
</body>
</html>