-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproductSorting_excluding_SoldOut.php
204 lines (200 loc) · 12.3 KB
/
productSorting_excluding_SoldOut.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
<!DOCTYPE html><!-- Last Published: Mon Nov 06 2023 05:41:27 GMT+0000 (Coordinated Universal Time) -->
<html data-wf-page="6545eca4ff3677790e075d32" data-wf-site="6541d9f4fbd73e9498319e4c">
<head>
<meta charset="utf-8">
<title>ThinkBig_Managing Online Shopping Mall Data</title>
<meta content="Product" property="og:title">
<meta content="Product" property="twitter:title">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link href="css/normalize.css" rel="stylesheet" type="text/css">
<link href="css/webflow.css" rel="stylesheet" type="text/css">
<link href="css/hahas-supercool-site.webflow.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com" rel="preconnect">
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js" type="text/javascript"></script>
<script type="text/javascript">
WebFont.load({
google: {
families: ["Changa One:400,400italic"]
}
});
</script>
<script type="text/javascript">
! function (o, c) {
var n = c.documentElement,
t = " w-mod-";
n.className += t + "js", ("ontouchstart" in o || o.DocumentTouch && c instanceof DocumentTouch) && (n.className += t + "touch")
}(window, document);
</script>
<link href="images/favicon.png" rel="shortcut icon" type="image/x-icon">
<link href="images/webclip.png" rel="apple-touch-icon">
</head>
<body>
<div data-animation="default" data-collapse="medium" data-duration="400" data-easing="ease" data-easing2="ease"
role="banner" class="navbar w-nav">
<div class="navbar-wrapper w-container">
<a href="notice.php" class="nav-btn w-nav-link">NOTICE</a>
<a href="user.php" class="nav-btn w-nav-link">USER</a>
<a href="brand.php" class="nav-btn w-nav-link">BRAND</a>
<a href="product.php" aria-current="page" class="nav-btn w-nav-link w--current" style="color: #3880eb">PRODUCT</a>
<a href="delivery.php" class="nav-btn w-nav-link">DELIVERY</a>
<a href="review.php" class="nav-btn w-nav-link">REVIEW</a>
<a href="coupon.php" class="nav-btn w-nav-link">COUPON</a>
<a href="qna.php" class="nav-btn w-nav-link">Q&A</a>
</div>
</div>
<section class="titlebar">
<a href="index.php" class="link-block w-inline-block"><img src="images/ThinkBig.png" loading="lazy" alt=""
class="image"></a>
</section>
<div id="w-node-_17ab5aa1-19f5-d367-e3c3-21d7eecd11bc-0e075d32" class="w-layout-layout block wf-layout-layout">
<div id="w-node-_17ab5aa1-19f5-d367-e3c3-21d7eecd11bd-0e075d32" class="w-layout-cell userinfo"><img
src="images/userImg.png" loading="lazy" width="100" height="100" alt="" class="userimage">
<div id="w-node-_17ab5aa1-19f5-d367-e3c3-21d7eecd11bf-0e075d32"
class="w-layout-layout info wf-layout-layout">
<div id="w-node-_17ab5aa1-19f5-d367-e3c3-21d7eecd11c0-0e075d32" class="w-layout-cell id">
<div class="user-info"><?php session_start(); echo $_SESSION['employeeID'];?></div>
</div>
<div id="w-node-_17ab5aa1-19f5-d367-e3c3-21d7eecd11c3-0e075d32" class="w-layout-cell name">
<div class="user-info"><?php echo $_SESSION['name'];?></div>
</div>
<div id="w-node-_17ab5aa1-19f5-d367-e3c3-21d7eecd11c6-0e075d32" class="w-layout-cell department">
<div class="user-info"><?php echo $_SESSION['department'];?></div>
</div>
</div>
</div>
<div id="w-node-_17ab5aa1-19f5-d367-e3c3-21d7eecd11c9-0e075d32" class="w-layout-cell content productcell">
<div class="div-block-5">
<div class="w-form" style="display:flex;">
<form id="productform" action="productSorting_excluding_SoldOut.php" method="POST" style="flex: 1;">
<select onchange="this.form.submit()" id="productfiled" name="sortBy" data-name="Field"
class="select-field w-select">
<?php
$sortBy = $_POST['sortBy'];
if ($sortBy == 'wishes') {
echo '<option value="wishes" selected>Wishes</option>
<option value="highestPrice">Highest Price</option>
<option value="lowestPrice">Lowest Price</option>
<option value="order">Order Quantity</option>
<option value="rating">Rating</option>';
}
if ($sortBy == 'highestPrice') {
echo '<option value="wishes" >Wishes</option>
<option value="highestPrice" selected>Highest Price</option>
<option value="lowestPrice">Lowest Price</option>
<option value="order">Order Quantity</option>
<option value="rating">Rating</option>';
}
if ($sortBy == 'lowestPrice') {
echo '<option value="wishes" >Wishes</option>
<option value="highestPrice">Highest Price</option>
<option value="lowestPrice" selected>Lowest Price</option>
<option value="order">Order Quantity</option>
<option value="rating">Rating</option>';
}
if ($sortBy == 'order') {
echo '<option value="wishes" >Wishes</option>
<option value="highestPrice">Highest Price</option>
<option value="lowestPrice">Lowest Price</option>
<option value="order" selected>Order Quantity</option>
<option value="rating">Rating</option>';
}
if ($sortBy == 'rating') {
echo '<option value="wishes" >Wishes</option>
<option value="highestPrice">Highest Price</option>
<option value="lowestPrice">Lowest Price</option>
<option value="order">Order Quantity</option>
<option value="rating" selected>Rating</option>';
}
?>
</select>
</form>
<form action="productSorting.php" method="POST" style="display:flex;">
<?php
echo '<input type="hidden" name="sortBy" value="' . $sortBy . '">';
?>
<input onchange="this.form.submit()" type="checkbox" name="soldOut" value="Y"
style="margin-left:10px; margin-right:5px;" checked><label for="soldOut"
style="padding-top:13px; margin-right:15px;">Excluding sold-out</label>
</form>
<div class="w-form-done">
<div>Thank you! Your submission has been received!</div>
</div>
<div class="w-form-fail">
<div>Oops! Something went wrong while submitting the form.</div>
</div>
</div>
</div>
<div class="div-block-6">
<div id="productcols" class="div-block-8 div-product">
<div id="product_rank_col" class="div-block-7">RANK</div>
<div id="product_productname_col" class="div-block-7 productnamecol">PRODUCT NAME </div>
<div id="product_brandname_col" class="div-block-7 brandnamecol">BRAND NAME</div>
<div id="product_price_col" class="div-block-7">TARGET</div>
<?php
if ($sortBy == "wishes") {
echo '<div id="product_price_col" class="div-block-7">wishCount</div>';
}
if ($sortBy == "highestPrice" || $sortBy == "lowestPrice") {
echo '<div id="product_price_col" class="div-block-7">price</div>';
}
if ($sortBy == "order") {
echo '<div id="product_price_col" class="div-block-7">orderCount</div>';
}
if ($sortBy == "rating") {
echo '<div id="product_price_col" class="div-block-7">avgRating</div>';
}
?>
</div>
<div class="productlists" style="max-height: 360px; overflow-y: auto;">
<?php
include "./dbConnection.php";
if ($sortBy == "wishes") {
$sql = "select RANK() over (ORDER BY count desc) as 'rank', productName,brandName,target,count as fivParam from wishCount natural join products natural join brands where stock!=0";
}
if ($sortBy == 'highestPrice') {
$sql = "select RANK() over (ORDER BY price desc) as 'rank',productName, brandName, target, price as fivParam from products natural join brands where stock!=0";
}
if ($sortBy == "lowestPrice") {
$sql = "select RANK() over (ORDER BY price asc) as 'rank',productName, brandName, target, price as fivParam from products natural join brands where stock!=0";
}
if ($sortBy == "order") {
$sql = "select RANK() over (ORDER BY count desc) as 'rank', productName,brandName,target,count as fivParam from orderCount natural join products natural join brands where stock!=0";
}
if ($sortBy == "rating") {
$sql = "select RANK() over (ORDER BY rating desc) as 'rank', productName,brandName,target,rating as fivParam from reviewRating natural join products natural join brands where stock!=0";
}
$res = mysqli_query($mysqli, $sql);
if ($res) {
while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$rank = $row["rank"];
$productName = $row['productName'];
$brandName = $row['brandName'];
$target = $row['target'];
$param = $row['fivParam'];
echo "
<div class='div-block-8'>
<div class='div-block-7 datarow'>" . $rank . "</div>
<div class='div-block-7 productnamecol datarow'>" . $productName . "</div>
<div class='div-block-7 brandnamecol datarow'>" . $brandName . "</div>
<div class='div-block-7 datarow'>" . $target . "</div>
<div class='div-block-7 datarow'>" . $param . "</div>
</div>
";
}
} else {
printf("%s", mysqli_error($mysqli));
}
mysqli_free_result($res);
mysqli_close($mysqli);
?>
</div>
</div>
</div>
</div>
<script src="https://d3e54v103j8qbb.cloudfront.net/js/jquery-3.5.1.min.dc5e7f18c8.js?site=6541d9f4fbd73e9498319e4c"
type="text/javascript" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"></script>
<script src="js/webflow.js" type="text/javascript"></script>
</body>
</html>