-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
360 lines (305 loc) · 8.02 KB
/
search.php
File metadata and controls
360 lines (305 loc) · 8.02 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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Displaying result</title>
<link rel="stylesheet" href="animated-menu.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.2r1/build/grids/grids-min.css">
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.js" type="text/javascript"></script>
<script src="js/jquery.easing.1.3.js" type="text/javascript"></script>
<script src="animated-menu.js" type="text/javascript"></script>
<!-- Load JavaScript files -->
<script type='text/javascript' src='js/jquery(2).js'></script>
<script type='text/javascript' src='js/jquery.simplemodal.js'></script>
<script type='text/javascript' src='js/contact.js'></script>
<script type='text/javascript' src='js/script.js'></script>
<!-- Script to redirect the user to the desired url on clicking anywhere on the row -->
<script type="text/javascript">
$(document).ready(function(){
$("tr").click(function(){
if($(this).attr("url"))// to avoid the header tags
window.location = $(this).attr("url");
});
});
</script>
<!-- Contact Form CSS files -->
<link type='text/css' href='css/contact.css' rel='stylesheet' media='screen' />
<!-- JS files are loaded at the bottom of the page -->
<style type="text/css">
td
{
text-align:center;
padding:10px;
}
#cont {
position: absolute;
width:100%;
margin:auto;
left: 11px;
top: 17px;
}
.left{
background-color:#F2F2F2;
padding: 15px;
font-size:12px;
}
.priceValues{
padding: 28px;
text-align:center;
}
.yui-gb img{
width: 80px;
height: 80px;
margin-left: 50px;
padding:30px;
}
.images{
width: 130px;
height: 130px;
padding:20px;
}
#descPara{
position: relative;
padding: 20px;
}
#dealLink{
color: RED;
}
.center{
background-color: #F2F2F2;
padding: 10px;
font-size:12px;
}
.right{
background-color: #F2F2F2;
padding: 25px;
font-size:12px;
}
td{
text-align:justify;
}
.price{
font-size:14px;
}
tr{
font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica,sans-serif;
color: #000000;
border-right: 1px solid #C1DAD7;
border-bottom: 1px solid #C1DAD7;
border-top: 1px solid #C1DAD7;
letter-spacing: 1px;
text-align: left;
padding: 6px 6px 6px 10px;
background: #CAE8EA;
}
tr:hover{
background: #AAA;
}
.header{
background-color:#888;
font-size:18px;
text-transform:uppercase;
}
.next{
background-color: #FF6;
}
.next:hover{
background-color: #F60;
}
.prev{
background-color: #FF6;
}
.prev:hover{
background-color: #F60;
}
.navigate{
list-style-position:outside;
}
</style>
</head>
<body>
<div id="cont">
<ul>
<li class="green">
<p><a href="index.php">Home</p>
<p class="subtext">The front page</a></p>
</li>
<li class="yellow">
<p><a href="about/about.php">About</p>
<p class="subtext">More info</a></p>
</li>
<li class="red">
<div id='container'>
<div id='content'>
<div id='contact-form'>
<p><a href="#" class='contact'>Contact</p>
<p class="subtext">Get in touch</a></p>
</div>
<div style='display:none'>
<img src='img/contact/loading.gif' alt='jkjk' />
</div>
</div>
</li>
<li class="blue">
<p><a href="CSS_gallery/index.php">Gallery</p>
<p class="subtext">See our stuff!</a></p>
</li>
<li class="purple">
<p><a href="terms.php">Terms</p>
<p class="subtext">Legal things</a></p>
</li>
<li class="new">
<form method="GET" action="search.php">
<div align="center" style="border:thick; background-color:#0292C0; padding: 12px; position: relative">
<input type="text" id="search" size="41" align="middle" width="300" name="search"/>
<select class="category" name="category">
<option>Select Category</option>
<option>Product name</option>
<option>Manufacturer's name</option>
<option>Model</option>
<input type="submit" value="Go"/>
</select>
</div>
</form>
</li>
</ul>
</div>
<br /><br />
<br />
<br />
<br />
</div>
<?php
$username="tjamadar";
$password="jamadar";
$database="tjamadar";
mysql_connect("db.ecst.csuchico.edu:5551",$username,$password);
if(@mysql_select_db($database) )
echo " ";
else
echo "<h1>Connection Failure</h1>";
error_reporting (E_ERRORS);
?>
<?php
$start = isset($_GET["limit"]) ? $_GET["limit"] : 0;
if(isset($_GET["search"]) && $_GET["search"] != "" || isset($_GET["query"]))
{
$search_criteria = $_GET["search"];
$category = $_GET["category"];
$limit = 10;
if(isset($_GET["query"]))
{
$search_criteria = $_GET["query"];
}
$temp = mysql_query("SELECT count(*) FROM deal WHERE Description LIKE '%".$search_criteria."%'");
$num_rows = mysql_fetch_array($temp);
$result = mysql_query("SELECT * FROM deal WHERE Description LIKE '%".$search_criteria."%' OR Name LIKE '%".$search_criteria."%' ORDER BY Price LIMIT $start,$limit"); ?>
<div class="navigate">
<table>
<tr>
<?php if($start>0)
{?>
<td class="prev">
<a style="color:#009;" href="search.php?limit=<?php echo $start-$limit ;?>&search=<?php echo $search_criteria; ?>">PREVIOUS PAGE </a>
</td>
<?php } ?>
<?php if($num_rows[0]> $start+$limit)
{?>
<td class="next">
<a style="color:#009;" href="search.php?limit=<?php echo $start+$limit ;?>&search=<?php echo $search_criteria; ?>">NEXT PAGE </a>
</td>
<?php }?>
</tr>
</table>
</div>
<br><br>
<?php
$num_rows_result = mysql_num_rows($result);
if($num_rows_result>0)
{
?>
<table>
<tr class="header">
<td>
<p align="center"><?php echo "".$search_criteria."\n";?></p>
</td>
<td>
<p align="center">Description</p>
</td>
<td>
<p align="center">Price</p>
</td>
</tr>
<?php $num_rows_result = mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
?>
<tr url="<?php echo $row["Deal_Link"]; ?>">
<td>
<a id="dealLink" href="<?php echo $row["Deal_Link"]; ?>"> <img class="images" border="0" src="<?php echo $row['Image_Link']; ?>"/>
</a><br>
</td>
<td width="940">
<font style="color:#080;"><?php echo $row['Name'].":"; ?> </font><br><hr>
<?php echo $row['Description']; ?> <br>
Go to Deal <a id="dealLink" href="<?php echo $row["Deal_Link"]; ?>">Click Here </a><br>
<p><a style="color:#000; font-size:14px;" href="review.php?searchID=<?php echo $row['Deal_ID']; ?>">Reviews
<?php
$cnt = mysql_query("SELECT * FROM review WHERE Deal_ID=".$row["Deal_ID"]." ");
$count = mysql_num_rows($cnt);
echo "(".$count.")";
?>
</a></p>
</td>
<td class="price">
<?php echo "$".$row['Price']; ?> <br>
</td>
</tr>
<?php }
$data = mysql_result($key);
$size = 0;
$i=0;
?>
<?php
if($_GET["search"])
mysql_query("INSERT INTO keyword(`key`) VALUES('".$_GET["search"]."')");
?>
<tr>
</tr>
</table>
<?php }
else
{
echo "No Donut for you. Please try again !! ";
}
?>
<br><br>
<div class="navigate">
<table>
<tr>
<?php if($start>0)
{?>
<td class="prev">
<a style="color:#009;" href="search.php?limit=<?php echo $start-$limit ;?>&search=<?php echo $search_criteria; ?>">PREVIOUS PAGE </a>
</td>
<?php } ?>
<?php if($num_rows[0]> $start+$limit)
{?>
<td class="next">
<a style="color:#009;" href="search.php?limit=<?php echo $start+$limit ;?>&search=<?php echo $search_criteria; ?>">NEXT PAGE </a>
</td>
<?php }
} // end of the if condition where no word is searched for
else
{
echo "No results found Please Enter a valid keyword";
}
?>
</tr>
</table>
</div>
</body>
</html>