-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
141 lines (129 loc) · 5.15 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
<?php include ( "inc/connect.inc.php" ); ?>
<?php
ob_start();
session_start();
if (!isset($_SESSION['user_login'])) {
$user = "";
}
else {
$user = $_SESSION['user_login'];
$result = mysqli_query($con, "SELECT * FROM user WHERE id='$user'");
$get_user_email = mysqli_fetch_assoc($result);
$uname_db = $get_user_email['firstName'];
}
if (isset($_REQUEST['keywords'])) {
$epid = mysqli_real_escape_string($con, $_REQUEST['keywords']);
if($epid != "" && ctype_alnum($epid)){
}else {
header('location: index.php');
}
}else {
header('location: index.php');
}
$search_value = "";
$search_value = trim($_GET['keywords']);
?>
<!DOCTYPE html>
<html>
<head>
<title>Search</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="homepageheader">
<div class="signinButton loginButton">
<div class="uiloginbutton signinButton loginButton" style="margin-right: 40px;">
<?php
if ($user!="") {
echo '<a style="text-decoration: none; color: #fff;" href="logout.php">LOG OUT</a>';
}
else {
echo '<a style="text-decoration: none; color: #fff;" href="signin.php">SIGN IN</a>';
}
?>
</div>
<div class="uiloginbutton signinButton loginButton" style="">
<?php
if ($user!="") {
echo '<a style="text-decoration: none; color: #fff;" href="profile.php?uid='.$user.'">Hi '.$uname_db.'</a>';
}
else {
echo '<a style="text-decoration: none; color: #fff;" href="login.php">LOG IN</a>';
}
?>
</div>
<div class="uiloginbutton signinButton loginButton" style="">
<a style="text-decoration: none; color: #fff;" href="shops.php">NEAR-BY GROCERY SHOPS</a>
</div>
</div>
<div style="float: left; margin: 5px 0px 0px 23px;">
<a href="index.php">
<img style=" height: 75px; width: 130px;" src="image/ebuybdlogo.png">
</a>
</div>
<div id="srcheader">
<form id="newsearch" method="get" action="search.php">
<?php
echo '<input type="text" class="srctextinput" name="keywords" size="21" maxlength="120" placeholder="Search Here..." value="'.$search_value.'"><input type="submit" value="search" class="srcbutton" >';
?>
</form>
<div class="srcclear"></div>
</div>
</div>
<div class="categolis">
<table>
<tr>
<th>
<a href="women/saree.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Saree</a>
</th>
<th><a href="women/ornament.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Ornament</a></th>
<th><a href="women/watch.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Watch</a></th>
<th><a href="women/perfume.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Perfume</a></th>
<th><a href="women/hijab.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Hijab</a></th>
<th><a href="women/tshirt.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">T-Shirt</a></th>
<th><a href="women/footwear.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">FootWear</a></th>
<th><a href="women/toilatry.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Toiletry</a></th>
<th><a href="women/grocery.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Grocery</a></th>
</tr>
</table>
</div>
<div style="padding: 30px 120px; font-size: 25px; margin: 0 auto; display: table; width: 98%;">
<div>
<?php
if (isset($_GET['keywords']) && $_GET['keywords'] != ""){
$search_value = trim($_GET['keywords']);
$getposts = mysqli_query($con, "SELECT * FROM products WHERE pName like '%$search_value%' ORDER BY id DESC") or die(mysql_error());
if ( $total = mysqli_num_rows($getposts)) {
echo '<ul id="recs">';
echo '<div style="text-align: center;"> '.$total.' Products Found... </div><br>';
while ($row = mysqli_fetch_assoc($getposts)) {
$id = $row['id'];
$pName = $row['pName'];
$price = $row['price'];
$description = $row['description'];
$picture = $row['picture'];
$item = $row['item'];
echo '
<ul style="float: left;">
<li style="float: left; padding: 0px 25px 25px 25px;">
<div class="home-prodlist-img"><a href="women/view_product.php?pid='.$id.'">
<img src="image/product/'.$item.'/'.$picture.'" class="home-prodlist-imgi">
</a>
<div style="text-align: center; padding: 0 0 6px 0;"> <span style="font-size: 15px;">'.$pName.'</span><br> Price: '.$price.' INR</div>
</div>
</li>
</ul>
';
}
}else {
echo "Nothing Found!";
}
}else {
echo "Input Someting...";
}
?>
</div>
</div>
</body>
</html>