forked from rossacheson/Tardis
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunsearch.php
More file actions
170 lines (156 loc) · 5.59 KB
/
runsearch.php
File metadata and controls
170 lines (156 loc) · 5.59 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
170
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="UTF-8">
<title>Tardis Electronics</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/tardis.css">
<link rel="apple-touch-icon" sizes="57x57" href="favicon/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="favicon/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="favicon/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="favicon/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="favicon/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="favicon/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="favicon/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="favicon/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="favicon/favicon-194x194.png" sizes="194x194">
<link rel="icon" type="image/png" href="favicon/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="favicon/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="favicon/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="favicon/manifest.json">
<link rel="mask-icon" href="favicon/safari-pinned-tab.svg" color="#5bbad5">
<meta name="apple-mobile-web-app-title" content="Tardis">
<meta name="application-name" content="Tardis">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="favicon/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<header>
<img src="images/TardisBanner1.png" class ="banner" alt="Tardis Electronics"/>
<nav>
<ul>
<li><a href="index.html">Home Page</a></li>
<li><a href="laptops.php">Laptops</a></li>
<li><a href="tvs.php">TVs</a></li>
<li><a href="phones.php">Phones</a></li>
<li><a href="accessories.php">Accessories</a></li>
<li><a href="cart.php">Cart</a></li>
</ul>
</nav>
</header>
<section class="maincontent">
<h2>Results</h2>
<?php
include("conn.php");
$brand=$_POST["key_word"];
$min_price=$_POST["min_price"];
$max_price=$_POST["max_price"];
$category=$_POST["category"];
if ( $category== "" && $min_price=="" &&$max_price=="" && $brand=="")
{
die('Please provide input in select and from fields.');
}
$queryString="select * from product where";
if ($category != "") {
$queryString .= " product_kind='$category' ";
}
if($max_price!= "" && $category =="")
{
$queryString .=" price <= '$max_price' ";
}
if($max_price!= "" && $category !="")
{
$queryString .=" and price <= '$max_price' ";
}
if($min_price!= "" && $max_price== "" && $category =="")
{
$queryString .=" price >= '$min_price' ";
}
if($min_price!= "" &&( $max_price!= "" || $category !=""))
{
if($min_price!="" && $max_price!="")
{
if($min_price<=$max_price)
{
$queryString .=" and price >= '$min_price' ";
}
else
{ die('min price is larger than max price');
}
}
else
{ $queryString .=" and price >= '$min_price' ";}
}
if($brand!= ""&& $max_price== "" && $min_price== "" && $category =="")
{
$queryString .=" name like '%" .$brand. "%'";
}
if($brand!= ""&& ($max_price!= "" || $min_price!= "" || $category !=""))
{
$queryString .=" and name like '%" .$brand. "%'";
}
$result=mysql_query($queryString, $conn);
while($row=mysql_fetch_array($result))
{
?>
<table border="1" class= "col-xs-12 col-sm-6 col-md-4">
<tr>
<td><?php echo $row["name"] ?></td>
</tr>
<tr>
<td>$<?php echo $row["price"] ?>     <a a href="buy.php?id=<?php echo $row["product_ID"]?>&name=<?php
echo $row["name"]?>">
<img src="images/tardis_add_to_cart.png" height="40px" width="120px"/>
</a>
</td>
</tr>
</table>
<?php
}
?>
</section>
<section class = "search col-xs-12">
<h2>Search</h2>
<form name="queryInput" action="runsearch.php" method="POST">
<table>
<tr>
<td>
Keyword:
</td>
<td>
<input type="text" name="key_word" />
</td>
</tr>
<tr>
<td>
Max Price:
</td>
<td>
<input type="text" name="max_price" />
</td>
</tr>
<tr>
<td>
Min Price:
</td>
<td>
<input type="text" name="min_price" />
</td>
</tr>
<tr>
<td>
Category:
</td>
<td>
<input type="text" name="category" />
</td>
</tr>
</table>
<input type="submit" value="Search">
</form>
</section>
</body>
</html>