This repository has been archived by the owner on Apr 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newArrival.php
executable file
·270 lines (238 loc) · 8.47 KB
/
newArrival.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
<?php
include('boilerplate.php');
$per_page = 12;
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$start_from = ($page - 1) * $per_page;
?>
<style>
#price_range {
height: 6px;
}
.ui-slider-handle {
height: 13px !important;
width: 13px !important;
background: #66FCF1 !important;
border-radius: 25px;
}
.ui-slider-range.ui-corner-all.ui-widget-header {
background: #333;
}
.sublist {
color: black;
font-size: 12px;
font-weight: bolder;
text-transform: uppercase;
}
.pricelist {
color: black;
font-size: 16px;
font-weight: bolder;
text-transform: uppercase;
}
</style>
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-8 produts-sidebar-filter">
<div class="filter-widget">
<h3 class="fw-title"><span class="badge badge-dark">PRICE</span></h3>
<input type="hidden" id="min_price_hide" value="1" />
<input type="hidden" id="max_price_hide" value="5000" />
<p id="price_show" class="pricelist">₹ 1 - ₹ 5000</p>
<div id="price_range"></div>
</div>
<div class="filter-widget">
<h3 class="fw-title"><span class="badge badge-dark">SECTIONS</span></h3>
<div class="fw-brand-check">
<?php
$query = "
SELECT DISTINCT(section) FROM product ORDER BY section ASC
";
$statement = $con->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach ($result as $row) {
$sql = "
SELECT section_name FROM section WHERE section_id = '$row[0]'
";
$exe = $connect->query($sql);
$name = $exe->fetch_assoc();
?>
<div class="bc-item">
<label for="<?php echo $name['section_name']; ?>">
<input type="checkbox" id="<?php echo $name['section_name']; ?>" class="filter_all section" value="<?php echo $row['section']; ?>">
<span class="checkmark"></span>
<p class="sublist"><?php echo $name['section_name']; ?></p>
</label>
</div>
<?php
}
?>
</div>
</div>
<div class="filter-widget">
<h3 class="fw-title"><span class="badge badge-dark">CATEGORY</span></h3>
<div class="fw-brand-check">
<?php
$query = "
SELECT DISTINCT(category) FROM product ORDER BY category ASC
";
$statement = $con->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach ($result as $row) {
$sql = "
SELECT category_name FROM category WHERE category_id = '$row[0]'
";
$exe = $connect->query($sql);
$name = $exe->fetch_assoc();
?>
<div class="bc-item">
<label for="<?php echo $name['category_name']; ?>">
<input type="checkbox" id="<?php echo $name['category_name']; ?>" class="filter_all category" value="<?php echo $row['category']; ?>">
<span class="checkmark"></span>
<p class="sublist"><?php echo $name['category_name']; ?></p>
</label>
</div>
<?php } ?>
</div>
</div>
<div class="filter-widget">
<h3 class="fw-title"><span class="badge badge-dark">BRANDS</span></h3>
<div class="fw-brand-check">
<?php
$query = "
SELECT DISTINCT(brand) FROM product ORDER BY brand ASC
";
$statement = $con->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach ($result as $row) {
$sql = "
SELECT brand_name FROM brand WHERE brand_id = '$row[0]'
";
$exe = $connect->query($sql);
$name = $exe->fetch_assoc();
?>
<div class="bc-item">
<label for="<?php echo $name['brand_name']; ?>">
<input type="checkbox" id="<?php echo $name['brand_name']; ?>" class="filter_all brand" value="<?php echo $row['brand']; ?>">
<span class="checkmark"></span>
<p class="sublist"><?php echo $name['brand_name']; ?></p>
</label>
</div>
<?php
}
?>
</div>
</div>
</div>
<div class="col-lg-9">
<div class="row filter_data"></div>
<style>
.center {
text-align: center;
}
.pagination {
display: inline-block;
margin-top: 15px;
margin-bottom: 15px;
}
.pagination a {
color: grey;
float: left;
padding: 8px 16px;
text-decoration: none;
transition: .3s;
}
.pagination a.active {
background-color: #66fcf1;
color: black;
}
.pagination a:hover:not(.active) {
background-color: #66fcf1;
color: black;
}
</style>
<?php
$query = "SELECT * FROM product WHERE section = 2";
$result = mysqli_query($connect, $query);
$total_posts = mysqli_num_rows($result);
$total_pages = ceil($total_posts / $per_page);
$page_url = $_SERVER['PHP_SELF'];
echo "<div class='center'><div class='pagination justify-content-center'>";
echo "
<a href ='$page_url?page=1'>First</a>";
for ($i = 1; $i <= $total_pages; $i++) : ?>
<a class="<?php if ($page == $i) {
echo 'active';
} ?>" href="<?php echo $page_url ?>?page=<?= $i; ?>"> <?= $i; ?> </a>
<?php endfor;
echo "<a href='$page_url?page=$total_pages' >Last</a>";
echo "</div></div>";
?>
</div>
</div>
</div>
<script>
$(document).ready(function() {
filter_data();
function filter_data() {
$('.filter_data');
var action = 'fetch_data';
var newArrival = 'newArrival';
var start_from = <?php echo $start_from; ?>;
var per_page = <?php echo $per_page; ?>;
var minimum_price = $('#min_price_hide').val();
var maximum_price = $('#max_price_hide').val();
var brand = get_filter('brand');
var category = get_filter('category');
var section = get_filter('section');
$.ajax({
url: "fetch.php",
method: "POST",
data: {
action: action,
newArrival: newArrival,
start_from: start_from,
per_page: per_page,
minimum_price: minimum_price,
maximum_price: maximum_price,
brand: brand,
category: category,
section: section
},
success: function(data) {
$('.filter_data').html(data);
}
});
}
function get_filter(class_name) {
var filter = [];
$('.' + class_name + ':checked').each(function() {
filter.push($(this).val());
});
return filter;
}
$('.filter_all').click(function() {
filter_data();
});
$('#price_range').slider({
range: true,
min: 1,
max: 5000,
values: [1, 5000],
step: 100,
stop: function(event, ui) {
$('#price_show').html(' ₹ ' + ui.values[0] + ' - ₹ ' + ui.values[1]);
$('#min_price_hide').val(ui.values[0]);
$('#max_price_hide').val(ui.values[1]);
filter_data();
}
});
});
</script>
<?php include('footer.php'); ?>