-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicSearch.php
More file actions
201 lines (136 loc) · 9.61 KB
/
basicSearch.php
File metadata and controls
201 lines (136 loc) · 9.61 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
<?php
include "connection.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>basic Search</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/home.css">
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<link rel="shortcut icon" href="img/logo/FOOD MART.png">
</head>
<body>
<?php include "header.php"; ?>
<hr />
<div class="col-12 justify-content-center mt-5">
<div class="row mb-3">
<div class="offset-4 offset-lg-1 col-4 col-lg-1 logo" style="height: 60px;"></div>
<div class="col-12 col-lg-6">
<div class="input-group mt-3 mb-3">
<input type="text" class="form-control shadow-none" aria-label="Text input with dropdown button" id="search_txt">
<select class="form-select d-none" style="max-width: 250px;" id="c1">
<option value="0">All Categories</option>
</select>
</div>
</div>
<div class="col-12 col-lg-2 d-grid">
<button class="btn btn-dark mt-3 mb-3" onclick="basicSearch(0);">Search</button>
</div>
<div class="col-12 col-lg-2 mt-2 mt-lg-4 text-center text-lg-start">
<a href="advancedSearch.php" class="text-decoration-none link-secondary fw-bold">Advanced</a>
</div>
</div>
</div>
<hr/>
<!--product-->
<div class="container-fluid p-5" id="menu">
<div class="row p-5" id="view_area">
<div class="col-12">
<div class="row mt-3 mb-3">
<?php
$product_rs = Database::search("SELECT * FROM `product` WHERE `status_status_id` = '1'");
$product_num = $product_rs->num_rows;
if ($product_num > 0) {
for ($z = 0; $z < $product_num; $z++) {
$product_data = $product_rs->fetch_assoc();
?>
<div class="col p-3">
<div class="card custom-card bg-secondary-subtle" style="width: 23rem;">
<div class="product-img">
<?php
$img_rs = Database::search("SELECT * FROM `product_img` WHERE `product_id` = '".$product_data["id"]."' ");
$img_num = $img_rs->num_rows;
$img_data = $img_rs->fetch_assoc();
if($img_num > 0) {
?>
<img src="<?php echo $img_data["img_path"]; ?>" alt="">
<?php
}else{
?>
<img src="img/box.png" alt="">
<?php
}
?>
</div>
<div class="text-center">
<strong><?php echo $product_data["title"]; ?></strong>
<p>Milano Foods</p>
</div>
<div class="text-center mb-1">
<p class="card-title"><?php echo $product_data["price"]; ?></p>
<?php
if($product_data["qty"] > 0){
?>
<span class="card-text text-warning fw-bold">In Stock</span>
<br>
<span class="card-text text-success fw-bold"><?php echo $product_data["qty"]; ?> Items Available</span>
<a href="#" class="cart-btn text-decoration-none" onclick="addToCart('<?php echo $product_data['id']; ?>','<?php echo $product_data['qty']; ?>');">
<i class='fa fa-shopping-cart text-dark'></i>Add to cart
</a>
<a href='singleProductView.php?id=<?php echo $product_data["id"]; ?>' class="buy-button mt-2 d-grid"><i class='bx bxs-shopping-bag'></i>Buy Now</a>
<?php
}else{
?>
<span class="card-text text-danger fw-bold">Out Of Stock</span>
<br>
<span class="card-text text-danger fw-bold">00 Items Available</span>
<a href="#" class="cart-btn text-decoration-none">
<i class='fa fa-shopping-cart text-dark'></i>Add to cart
</a>
<a href="" class="buy-button btn btn-danger mt-2 d-grid disabled">Buy Now</a>
<?php
}
?>
</div>
<?php
if(isset($_SESSION["u"])){
$watchlist_rs = Database::search("SELECT * FROM `watchlist` WHERE `users_email` = '".$_SESSION["u"]["email"]."' AND
`product_id` = '".$product_data["id"]."'");
$watchlist_num = $watchlist_rs->num_rows;
if($watchlist_num == 1){
?>
<a href="#" class="like-btn text-danger" onclick="addToWatchlist(<?php echo $product_data['id']; ?>);">
<i id="heart<?php echo $product_data['id']; ?>" class="bi bi-heart-fill"></i>
</a>
<?php
}else{
?>
<a href="#" class="like-btn text-dark" onclick="addToWatchlist(<?php echo $product_data['id']; ?>);">
<i id="heart<?php echo $product_data['id']; ?>" class="bi bi-heart-fill"></i>
</a>
<?php
}
}
?>
</div>
</div>
<?php
}
}
?>
</div>
</div>
</div>
</div>
<!--product-->
<script src="js/script.js"></script>
<script src="https://unpkg.com/boxicons@2.1.4/dist/boxicons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script type="text/javascript" src="https://www.payhere.lk/lib/payhere.js"></script>
</body>
</html>