-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaitingOrdersCarts.php
executable file
·128 lines (96 loc) · 3.41 KB
/
waitingOrdersCarts.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
<!DOCTYPE html>
<html>
<head>
<title>Waiting Orders Carts</title>
<link rel="stylesheet" href="globalUsage/style.css" class="">
</head>
<body>
<?php include "globalUsage/dropdownmenu.html"?>
<h1> <u>Waiting Carts</u></h1>
<form action="waitingOrdersComputer.php" method="post">
<input type="submit" value="Computerboxes" class="otherProduct">
</form>
<br>
<?php include "globalUsage/searchbar.html"?>
<br><br>
<form action="waitingOrdersCarts.php" method="post" class= "sameLine">
<select name="wheelcolor" id="wheelcolor" class = "dropdown sameLine">
<option value="nothing">Choose wheel color</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="grey">Grey</option>
</select>
<select name="wheeltype" id="wheeltype" class = "dropdown sameLine">
<option value="nothing">Choose wheel type</option>
<option value="fix">Fix</option>
<option value="mobile">Mobile</option>
</select>
<input type="submit" value = "Update criteria" class = "updateCriteria">
</form>
<br><br><br><br><br>
<table class = "waiting">
<tr class = "waiting">
<th>id</th>
<th>order_time</th>
<th>status</th>
<th>nbr_products</th>
<th>wheel_color</th>
<th>wheel_type</th>
</tr>
<?php
$flaw_type = "scratch";
$severity = "low";
$flaw_query = "UPDATE flaw_count SET count = count + 1 WHERE flaw_type = '$flaw_type' AND severity = '$severity'";
mysqli_query($link, $flaw_query);
require 'globalUsage/db.php';
if(isset($_POST['wheelcolor'])){
$color = $_POST['wheelcolor'];
}else $color = "";
if(isset($_POST['wheeltype'])){
$type = $_POST['wheeltype'];
}else $type = "";
// we create the right query according to the restrictions
$query = "";
if($color != "nothing" && $type != "nothing" && $color != "" && $type != ""){
$query = "SELECT * FROM orders INNER JOIN carts ON orders.reference_id = carts.id WHERE orders.product = 'carts' AND orders.status = 'waiting'
AND (carts.wheel_type = '$type' AND carts.wheel_color = '$color')";
}else if($color == "nothing" && $type != "nothing"){
$query = "SELECT * FROM orders INNER JOIN carts ON orders.reference_id = carts.id WHERE orders.product = 'carts' AND orders.status = 'waiting'
AND carts.wheel_type = '$type'";
}
else if($type == "nothing" && $color != "nothing"){
$query = "SELECT * FROM orders INNER JOIN carts ON orders.reference_id = carts.id WHERE orders.product = 'carts' AND orders.status = 'waiting'
AND carts.wheel_color = '$color'";
}else{
$query = "SELECT * FROM orders INNER JOIN carts ON orders.reference_id = carts.id WHERE orders.product = 'carts' AND orders.status = 'waiting' ";
}
if ($result = mysqli_query($link, $query)){
if (mysqli_num_rows($result) > 0){
$i = 0;
while(($row = mysqli_fetch_assoc($result)) && $i<100){
echo "<tr><td>"
. $row["id"] . "</td><td>"
. $row["order_time"] . "</td><td>"
. $row["status"] . "</td><td>"
. $row["nbr_products"] . "</td><td>"
. $row["wheel_color"] . "</td><td>"
. $row["wheel_type"] .
"</td></tr>" ;
$i ++;
}
echo "</table>";
}else{
echo "0 results";
}
mysqli_free_result($result);
}
else if (!$result){
$message = 'Invalid query: ' .mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
mysqli_close($link);
?>
</table>
</body>
</html>