-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsortProcess.php
162 lines (139 loc) · 5.95 KB
/
sortProcess.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
<?php
session_start();
include "connection.php";
$user = $_SESSION["u"]["email"];
$search = $_POST["s"];
$time = $_POST["t"];
$qty = $_POST["q"];
$condition = $_POST["c"];
$query = "SELECT * FROM `product` WHERE `user_email`='" . $user . "'";
if (!empty($search)) {
$query .= " AND `title` LIKE '%" . $search . "%'";
}
if ($condition != "0") {
$query .= " AND `condition_condition_id`='" . $condition . "'";
}
if ($time != "0") {
if ($time == "1") {
$query .= " ORDER BY `datetime_added` DESC";
} else if ($time == "2") {
$query .= " ORDER BY `datetime_added` ASC";
}
}
if ($time != "0" && $qty != "0") {
if ($qty == "1") {
$query .= " , `qty` DESC";
} else if ($qty == "2") {
$query .= " , `qty` ASC";
}
} else if ($time == "0" && $qty != "0") {
if ($qty == "1") {
$query .= " ORDER BY `qty` DESC";
} else if ($qty == "2") {
$query .= " ORDER BY `qty` ASC";
}
}
?>
<div class="offset-1 col-10 text-center">
<div class="row justify-content-center">
<?php
if ("0" != ($_POST["page"])) {
$pageno = $_POST["page"];
} else {
$pageno = 1;
}
$product_rs = Database::search($query);
$product_num = $product_rs->num_rows;
$results_per_page = 12;
$number_of_pages = ceil($product_num / $results_per_page);
$page_results = ($pageno - 1) * $results_per_page;
$selected_rs = Database::search($query . " LIMIT " . $results_per_page . " OFFSET " . $page_results . "");
$selected_num = $selected_rs->num_rows;
for ($x = 0; $x < $selected_num; $x++) {
$selected_data = $selected_rs->fetch_assoc();
?>
<!-- Start Column -->
<div class="col-12 col-md-4 col-lg-3 mb-5">
<a style="height: 400px;" class="product-item">
<?php
$product_img_rs = Database::search("SELECT * FROM `product_img` WHERE `product_id`='" . $selected_data["id"] . "'");
$product_img_data = $product_img_rs->fetch_assoc();
?>
<img src="<?php echo $product_img_data["img_path"]; ?>" class="img-fluid product-thumbnail">
<h3 class="product-title"><?php echo $selected_data["title"]; ?></h3>
<strong class="product-price">Rs. <?php echo $selected_data["price"]; ?> .00</strong>
<?php if ($selected_data["qty"] > 0) { ?>
<h4 class="product-title"></h4>
<?php } else { ?>
<h4 class="product-title" style="color: red;">Sold Out!</h4>
<?php } ?>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="toggle<?php echo $selected_data["id"]; ?>" onchange="changeStatus(<?php echo $selected_data['id']; ?>);" <?php if ($selected_data["status_status_id"] == 2) { ?> checked <?php } ?> />
<label class="form-check-label fw-bold text-info" for="toggle<?php echo $selected_data["id"]; ?>">
<?php if ($selected_data["status_status_id"] == 1) { ?>
Make Your Product Deactive
<?php } else { ?>
Make Your Product Active
<?php } ?>
</label>
</div>
<div class="row">
<div class="col-12">
<div class="row g-1">
<div class="col-12 d-grid">
<button class="btn btn-success fw-bold" onclick="sendid(<?php echo $selected_data['id']; ?>);">
Update
</button>
</div>
</div>
</div>
</div>
</a>
</div>
<!-- End Column -->
<?php
}
?>
</div>
</div>
<!-- <div class="offset-2 offset-lg-3 col-8 col-lg-6 text-center mb-3">
<nav aria-label="Page navigation example">
<ul class="pagination pagination-lg justify-content-center">
<li class="page-item">
<a class="page-link" <?php if ($pageno <= 1) {
echo ("#");
} else {
?> onclick="sort1(<?php echo ($pageno - 1); ?>);" ; <?php
} ?> aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<?php
for ($x = 1; $x <= $number_of_pages; $x++) {
if ($x == $pageno) {
?>
<li class="page-item active">
<a class="page-link" onclick="sort1(<?php echo ($x); ?>);"><?php echo $x; ?></a>
</li>
<?php
} else {
?>
<li class="page-item">
<a class="page-link" onclick="sort1(<?php echo ($x); ?>);"><?php echo $x; ?></a>
</li>
<?php
}
}
?>
<li class="page-item">
<a class="page-link" <?php if ($pageno >= $number_of_pages) {
echo ("#");
} else {
?> onclick="sort1(<?php echo ($pageno + 1); ?>);" ; <?php
} ?> aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div> -->