-
-
Notifications
You must be signed in to change notification settings - Fork 391
/
homeaction.php
179 lines (148 loc) · 5.75 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
<?php
session_start();
$ip_add = getenv("REMOTE_ADDR");
include "db.php";
if(isset($_POST["categoryhome"])){
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>";
$category_query = "SELECT * FROM categories";
$run_query = mysqli_query($con,$category_query) or die(mysqli_error($con));
if(mysqli_num_rows($run_query) > 0){
while($row = mysqli_fetch_array($run_query)){
$cid = $row["cat_id"];
$cat_name = $row["cat_title"];
echo"<li><a href='products.php?cat_id=".$cid."'>$cat_name</a></li>";
}
}
// <li><a href='electronics.php'>Electronics</a></li>
// <li><a href='ladies_wears.php'>Ladies Wears</a></li>
// <li><a href='mens_wear.php'>Mens Wear</a></li>
// <li><a href='kids_wear.php'>Kids Wear</a></li>
// <li><a href='furnitures.php'>Furnitures</a></li>
// <li><a href='home_appliances.php'>Home Appliances</a></li>
// <li><a href='electronics_gadgets.php'>Electronics Gadgets</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'>";
$rating_query = "SELECT ROUND(AVG(rating),1) AS avg_rating FROM reviews WHERE product_id='$pro_id '";
$run_review_query = mysqli_query($con,$rating_query);
$review_row = mysqli_fetch_array($run_review_query);
if($review_row > 0){
$avg_count=$review_row["avg_rating"];
$i=1;
while($i <= round($avg_count)){
$i++;
echo'
<i class="fa fa-star"></i>';
}
$i=1;
while($i <= 5-round($avg_count)){
$i++;
echo'
<i class="fa fa-star-o empty"></i>';
}
}
echo "</div>
<div class='product-btns'>
<button pid='$pro_id' id='wishlist' 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>
";
}
;
}
}