-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsortProcess.php
More file actions
169 lines (145 loc) · 6.33 KB
/
sortProcess.php
File metadata and controls
169 lines (145 loc) · 6.33 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
<?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 = 5;
$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();
?>
<!-- card -->
<div class="card mb-3 mt-3 col-12 col-lg-6">
<div class="row">
<div class="col-md-4 mt-2">
<?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 rounded-start img-thumbnail" />
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title fw-bold"><?php echo $selected_data["title"]; ?></h5>
<span class="card-text fw-bold text-primary">Rs. <?php echo $selected_data["price"]; ?> .00</span><br />
<span class="card-text fw-bold text-success"><?php echo $selected_data["qty"]; ?> Items left</span>
<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">Update</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- card -->
<?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>