-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
homeaction.php
225 lines (188 loc) · 7.84 KB
/
homeaction.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
223
224
225
<?php
session_start();
$ip_add = getenv("REMOTE_ADDR");
include "db.php";
if(isset($_POST["categoryhome"])){
$category_query = "SELECT * FROM categories WHERE cat_id!=1";
$run_query = mysqli_query($con,$category_query) or die(mysqli_error($con));
echo "
<!-- responsive-nav -->
<div id='responsive-nav'>
<!-- NAV -->
<ul class='main-nav nav navbar-nav'>
<li class='active'><a href='index.php'>Home</a></li>
<li><a href='store.php'>Electronics</a></li>
";
if(mysqli_num_rows($run_query) > 0){
while($row = mysqli_fetch_array($run_query)){
$cid = $row["cat_id"];
$cat_name = $row["cat_title"];
$sql = "SELECT COUNT(*) AS count_items FROM products,categories WHERE product_cat=cat_id";
$query = mysqli_query($con,$sql);
$row = mysqli_fetch_array($query);
$count=$row["count_items"];
echo "
<li class='categoryhome' cid='$cid'><a href='store.php'>$cat_name</a></li>
";
}
echo "</ul>
<!-- /NAV -->
</div>
<!-- /responsive-nav -->
";
}
}
if(isset($_POST["page"])){
$sql = "SELECT * FROM products";
$run_query = mysqli_query($con,$sql);
$count = mysqli_num_rows($run_query);
$pageno = ceil($count/2);
for($i=1;$i<=$pageno;$i++){
echo "
<li><a href='#product-row' page='$i' id='page'>$i</a></li>
";
}
}
if(isset($_POST["getProducthome"])){
$limit = 3;
if(isset($_POST["setPage"])){
$pageno = $_POST["pageNumber"];
$start = ($pageno * $limit) - $limit;
}else{
$start = 0;
}
$product_query = "SELECT * FROM products,categories WHERE product_cat=cat_id LIMIT $start,$limit";
$run_query = mysqli_query($con,$product_query);
if(mysqli_num_rows($run_query) > 0){
while($row = mysqli_fetch_array($run_query)){
$pro_id = $row['product_id'];
$pro_cat = $row['product_cat'];
$pro_brand = $row['product_brand'];
$pro_title = $row['product_title'];
$pro_price = $row['product_price'];
$pro_image = $row['product_image'];
$cat_name = $row["cat_title"];
echo "
<div class='product-widget'>
<a href='product.php?p=$pro_id'>
<div class='product-img'>
<img src='product_images/$pro_image' alt=''>
</div>
<div class='product-body'>
<p class='product-category'>$cat_name</p>
<h3 class='product-name'><a href='product.php?p=$pro_id'>$pro_title</a></h3>
<h4 class='product-price'>$pro_price<del class='product-old-price'>$990.00</del></h4>
</div></a>
</div>
";
}
}
}
if(isset($_POST["gethomeProduct"])){
$limit = 9;
if(isset($_POST["setPage"])){
$pageno = $_POST["pageNumber"];
$start = ($pageno * $limit) - $limit;
}else{
$start = 0;
}
$product_query = "SELECT * FROM products,categories WHERE product_cat=cat_id AND product_id BETWEEN 71 AND 74";
$run_query = mysqli_query($con,$product_query);
if(mysqli_num_rows($run_query) > 0){
while($row = mysqli_fetch_array($run_query)){
$pro_id = $row['product_id'];
$pro_cat = $row['product_cat'];
$pro_brand = $row['product_brand'];
$pro_title = $row['product_title'];
$pro_price = $row['product_price'];
$pro_image = $row['product_image'];
$cat_name = $row["cat_title"];
echo "
<div class='col-md-3 col-xs-6'>
<a href='product.php?p=$pro_id'><div class='product'>
<div class='product-img'>
<img src='product_images/$pro_image' style='max-height: 170px;' alt=''>
<div class='product-label'>
<span class='sale'>-30%</span>
<span class='new'>NEW</span>
</div>
</div></a>
<div class='product-body'>
<p class='product-category'>$cat_name</p>
<h3 class='product-name header-cart-item-name'><a href='product.php?p=$pro_id'>$pro_title</a></h3>
<h4 class='product-price header-cart-item-info'>$pro_price<del class='product-old-price'>$990.00</del></h4>
<div class='product-rating'>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
</div>
<div class='product-btns'>
<button class='add-to-wishlist'><i class='fa fa-heart-o'></i><span class='tooltipp'>add to wishlist</span></button>
<button class='add-to-compare'><i class='fa fa-exchange'></i><span class='tooltipp'>add to compare</span></button>
<button class='quick-view'><i class='fa fa-eye'></i><span class='tooltipp'>quick view</span></button>
</div>
</div>
<div class='add-to-cart'>
<button pid='$pro_id' id='product' class='add-to-cart-btn block2-btn-towishlist' href='#'><i class='fa fa-shopping-cart'></i> add to cart</button>
</div>
</div>
</div>
";
}
;
}
}
if(isset($_POST["get_seleted_Category"]) || isset($_POST["search"])){
if(isset($_POST["get_seleted_Category"])){
$id = $_POST["cat_id"];
$sql = "SELECT * FROM products,categories WHERE product_cat = '$id' AND product_cat=cat_id";
}else {
$keyword = $_POST["keyword"];
$sql = "SELECT * FROM products,categories WHERE product_cat=cat_id AND product_keywords LIKE '%$keyword%'";
}
$run_query = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($run_query)){
$pro_id = $row['product_id'];
$pro_cat = $row['product_cat'];
$pro_brand = $row['product_brand'];
$pro_title = $row['product_title'];
$pro_price = $row['product_price'];
$pro_image = $row['product_image'];
$cat_name = $row["cat_title"];
echo "
<div class='col-md-4 col-xs-6'>
<a href='product.php?p=$pro_id'><div class='product'>
<div class='product-img'>
<img src='product_images/$pro_image' style='max-height: 170px;' alt=''>
<div class='product-label'>
<span class='sale'>-30%</span>
<span class='new'>NEW</span>
</div>
</div></a>
<div class='product-body'>
<p class='product-category'>$cat_name</p>
<h3 class='product-name header-cart-item-name'><a href='product.php?p=$pro_id'>$pro_title</a></h3>
<h4 class='product-price header-cart-item-info'>$pro_price<del class='product-old-price'>$990.00</del></h4>
<div class='product-rating'>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
</div>
<div class='product-btns'>
<button class='add-to-wishlist' tabindex='0'><i class='fa fa-heart-o'></i><span class='tooltipp'>add to wishlist</span></button>
<button class='add-to-compare'><i class='fa fa-exchange'></i><span class='tooltipp'>add to compare</span></button>
<button class='quick-view' ><i class='fa fa-eye'></i><span class='tooltipp'>quick view</span></button>
</div>
</div>
<div class='add-to-cart'>
<button pid='$pro_id' id='product' href='#' tabindex='0' class='add-to-cart-btn'><i class='fa fa-shopping-cart'></i> add to cart</button>
</div>
</div>
</div>
";
}
}