-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsearch.php
222 lines (182 loc) · 7.95 KB
/
search.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Everest - Search Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../css/main.css" />
<link rel= "stylesheet" type="text/css" href = "../css/header_style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<style>
.tooltiptext {
visibility: hidden;
width: 120px;
color: #fff;
text-align: center;
border-radius: 6px;
/* Position the tooltip */
position: absolute;
z-index: 1;
top: 100%;
left: 50%;
margin-left: -21px;
margin-top: -14px;
}
.tooltiptext {
visibility: visible;
}
</style>
<!-- HEADER -->
<div id = "header">
<div style="float:left;height:50px;width:15%;min-width:120px;">
<a href = "/">
<img type = "everest_logo" src = "/imgs/everest-logo.png" alt = "Everest Logo" style="padding-left:28px;width: 107px;"/>
</a>
</div>
<?php
include_once ('./config.php');
$conn=mysqli_connect($servername,$username,$password,$dbname);
if (mysqli_connect_errno())
{
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
if(isset($_COOKIE['UID']))
{
//$_COOKIE['UID'];
$userid= $_COOKIE['UID'];
$query="select ccID from team_best_rds.tbl_credit_card where userID=$userid";
$result = mysqli_query($conn,$query);
if($row = mysqli_fetch_array($result))
{
$ccID = $row['ccID'];
}
else{$ccID=0;}
$query="select * from team_best_rds.tbl_orders where ccID = $ccID and cart =1";
$result = mysqli_query($conn,$query);
if($row = mysqli_fetch_array($result)){//if an order exist
$orderID=$row['orderID'];
$query="SELECT COUNT(*) as count FROM team_best_rds.tbl_orderdetails where orderID = $orderID";
$result = mysqli_query($conn,$query);
$row = mysqli_fetch_array($result);
echo'<a href="cart.php"style="color:white;margin-left: 67%;position: absolute;top: 15px; " ><span class="glyphicon glyphicon-shopping-cart"> Cart</span><span class = "tooltiptext">('.$row['count'].') </span> </a>';
}else{//if there's no order yet
echo'<a href="cart.php"style="color:white;margin-left: 67%;position: absolute;top: 15px; " ><span class="glyphicon glyphicon-shopping-cart"> Cart</span><span class = "tooltiptext"> (0) </span> </a>
';
}
}else{
echo'<a href="cart.php"style="color:white;margin-left: 67%;position: absolute;top: 15px; " ><span class="glyphicon glyphicon-shopping-cart"> Cart</span><span class = "tooltiptext"> </span> </a>';
}
?>
<form method="post" action="search.php" name="form">
<div id="search">
<input name = "searchbar" id = "searchbox" type="text" size="30" onkeyup="showResult(this.value)" placeholder="Search for an item..." />
</div>
</form>
<?php
if(isset($_COOKIE['email']) == "") {
echo '<a href="login.php"style="color:white;margin-left: 75%;position: absolute;top: 15px;" ><span class="glyphicon glyphicon-log-in"> Login</span> </a>
<a href="myaccount.php"style="color:white;margin-left: 41%;position: absolute;top: 15px;display:none"><span class="glyphicon glyphicon-user"> My Account</span> </a>
<a href="logout.php"style="color:white;margin-left: 75%;position: absolute;top: 15px;display:none"><span class="glyphicon glyphicon-log-out"> Logout</span> </a>
';
} else {
echo'
<a href="myaccount.php"style="color:white;margin-left: 41%;position: absolute;top: 15px;"><span class="glyphicon glyphicon-user"> My Account</span> </a>
<a href="logout.php"style="color:white;margin-left: 75%;position: absolute;top: 15px;"><span class="glyphicon glyphicon-log-out"> Logout</span> </a>
<a href="login.php"style="color:white;margin-left: 75%;position: absolute;top: 15px; display:none" ><span class="glyphicon glyphicon-log-in"> Login</span> </a>
';
}
?>
</div> <!-- End of Div header -->
<div id="wrapper">
<div id="content_inside">
<div id="sidebar">
<h3>CATEGORIES</h3>
<?php
include_once ('./getcat.php');
?>
</div>
<div id="main_block">
<div class="about">
<?php
if(isset($_COOKIE['name']) == "") {
echo'
<h3> Welcome guest user...</h3>
<br>
</div>
';
}
else{
echo'
<h3> Welcome '.$_COOKIE['name'].'...</h3>
<br>
</div>
';
}
?>
<div id="items">
<div id="items">
<!--SEARCH FUNCTION HERE -->
<?php
include_once ('./config.php');
$item_total=0;
$con=mysqli_connect($servername,$username,$password,$dbname);
if (mysqli_connect_errno())
{
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
$search = $_POST["searchbar"];
$sql = "SELECT * FROM tbl_items WHERE qty!=0 and name like '%$search%' and itemID <>9999";
$result = $con->query($sql);
while ($row = mysqli_fetch_array($result)) {
if($row['isBid']==0)
{
echo '
<div class="item">
<img src="./imgs/'.$row['itemID'].'.jpg" alt="" width="202" height="173" /><br />
<span>$'.$row['itemprice']. '</span>
<a href="item.php?itemid='.$row['itemID'].'&category=9 " class="view">'.$row['name'].'</a>
<a class="cart" href="addtocart.php?itemid='.$row['itemID'].'">Add To Cart</a>
</div>
';
}else{
echo '
<div class="item">
<img src="./imgs/'.$row['itemID'].'.jpg" alt="" width="202" height="173" /><br />
<span>$'.$row['itemprice']. '</span>
<a href="item.php?itemid='.$row['itemID'].'&category=9 " class="view">'.$row['name'].'</a>
<a class="cart" href="addtocart.php?itemid='.$row['itemID'].'">Place a Bid</a>
</div>';
}
}
$con->close();
?>
<!-- END OF SEARCH-->
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer_inside">
<ul class="footer_menu">
<li><a href="index.html">Home Page</a>|</li>
<li><a href="index2.html">About Us</a>|</li>
<li><a href="index2.html">News & Events</a>|</li>
<li><a href="index2.html">Services</a>|</li>
<li><a href="index2.html">My Account</a>|</li>
<li><a href="index2.html">Contacts</a></li>
</ul><br /><br />
<p>Copyright ©. All rights reserved. Design by Team Best - CMPSC 431W</p>
</div>
</div>
<map name="Map">
<area shape="rect" coords="78,45,312,119" href="index.html">
<area shape="poly" coords="670,87,719,78,727,123,677,130" href="#">
<area shape="poly" coords="776,124,818,152,793,189,751,160" href="#">
<area shape="poly" coords="834,52,885,61,878,105,828,96" href="#">
</map>
</body>
</html>