-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-product.php
396 lines (372 loc) · 21 KB
/
single-product.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<?php include("header.php"); ?>
<!-- breadcrumb-section start -->
<nav class="breadcrumb-section theme3 bg-lighten2 pt-110 pb-110">
<div class="container">
<div class="row">
<div class="col-12">
<ol class="breadcrumb bg-transparent m-0 p-0 align-items-center justify-content-center">
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
<li class="breadcrumb-item"><a href="shop.php">Shop</a></li>
<li class="breadcrumb-item active" aria-current="page">Single Product</li>
</ol>
</div>
</div>
</div>
</nav>
<?php
include('connect.php');
$id = $_GET['id'];
$query = "SELECT * FROM `products` WHERE `id`='".$id."'";
$run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($run)) {
$id = $row["id"];
$product_name = $row["name"];
$pro_category = $row["cname"];
$pro_desc = $row["description"];
$pro_price = $row["price"];
$pro_image = $row["picture"];
$pgallery = $row["pgallery"]; // gallery images
$final = unserialize($pgallery); // gallery images
} ?>
<section class="product-single theme3 pt-60">
<div id="message"></div>
<div class="container">
<div class="row">
<div class="col-lg-6 mb-5 mb-lg-0">
<div class="position-relative">
<span class="badge badge-danger top-right">New</span>
</div>
<div class="product-sync-init mb-20">
<div class="single-product">
<div class="product-thumb">
<img src="admin/productimgs/<?php echo $pro_image; ?>" alt="product-thumb">
</div>
</div>
<!-- single-product end -->
<div class="single-product">
<div class="product-thumb">
<img src="admin/productimgs/<?php echo $final[0]; ?>" alt="product-thumb">
</div>
</div>
<!-- single-product end -->
<div class="single-product">
<div class="product-thumb">
<img src="admin/productimgs/<?php echo $final[1]; ?>" alt="product-thumb">
</div>
</div>
<!-- single-product end -->
<div class="single-product">
<div class="product-thumb">
<img src="admin/productimgs/<?php echo $final[2]; ?>" alt="product-thumb">
</div>
</div>
<!-- single-product end -->
</div>
<div class="product-sync-nav single-product">
<div class="single-product">
<div class="product-thumb">
<a href="javascript:void(0)"> <img src="admin/productimgs/<?php echo $pro_image; ?>"></a>
</div>
</div>
<!-- single-product end -->
<div class="single-product">
<div class="product-thumb">
<a href="javascript:void(0)"> <img src="admin/productimgs/<?php echo $final[0]; ?>"></a>
</div>
</div>
<!-- single-product end -->
<div class="single-product">
<div class="product-thumb">
<a href="javascript:void(0)"><img src="admin/productimgs/<?php echo $final[1]; ?>"></a>
</div>
</div>
<!-- single-product end -->
<div class="single-product">
<div class="product-thumb">
<a href="javascript:void(0)"><img src="admin/productimgs/<?php echo $final[2]; ?>"></a>
</div>
</div>
<!-- single-product end -->
</div>
</div>
<div class="col-lg-6 mt-5 mt-md-0">
<div class="single-product-info">
<div class="single-product-head">
<h2 class="title mb-20"><?php echo $product_name; ?></h2>
<div class="star-content mb-20">
<span class="star-on"><i class="ion-ios-star"></i> </span>
<span class="star-on"><i class="ion-ios-star"></i> </span>
<span class="star-on"><i class="ion-ios-star"></i> </span>
<span class="star-on"><i class="ion-ios-star"></i> </span>
<span class="star-on"><i class="ion-ios-star"></i> </span>
<a href="#" id="write-comment"><span class="ml-2"><i class="far fa-comment-dots"></i></span>
Read reviews <span>(1)</span></a>
<a href="#" data-toggle="modal" data-target="#exampleModalCenter"><span class="edite"><i
class="far fa-edit"></i></span> Write a review</a>
</div>
</div>
<div class="product-body mb-40">
<div class="d-flex align-items-center mb-30">
<h6 class="product-price mr-20"><del class="del">$23.90</del>
<span class="onsale">Rs. <?php echo $pro_price; ?></span></h6>
<span class="badge position-static bg-dark rounded-0">Save 10%</span>
</div>
<p><?php echo $pro_desc; ?></p>
</div>
<div class="product-footer">
<div class="product-count style d-flex flex-column flex-sm-row mt-30 mb-30">
<div class="count d-flex">
<input type="number" id="qty" name="qty" min="1" max="10" step="1" value="1">
<div class="button-group">
<button class="count-btn increment"><i class="fas fa-chevron-up"></i></button>
<button class="count-btn decrement"><i class="fas fa-chevron-down"></i></button>
</div>
</div>
<div>
<form class="form-submit">
<input type="hidden" class="pid" value="<?php echo $id; ?>">
<input type="hidden" class="pname" value="<?php echo $product_name; ?>">
<input type="hidden" class="pprice" value="<?php echo $pro_price; ?>">
<input type="hidden" class="pimage" value="<?php echo $pro_image; ?>">
<button id="addItem" class="btn theme-btn--dark3 btn--xl mt-5 mt-sm-0 rounded-5">Add to cart</button>
</form>
</div>
</div>
<div class="addto-whish-list">
<a href="#"><i class="icon-heart"></i> Add to wishlist</a>
</div>
<div class="pro-social-links mt-10">
<ul class="d-flex align-items-center">
<li class="share">Share</li>
<li><a href="#"><i class="ion-social-facebook"></i></a></li>
<li><a href="#"><i class="ion-social-twitter"></i></a></li>
<li><a href="#"><i class="ion-social-google"></i></a></li>
<li><a href="#"><i class="ion-social-pinterest"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- product-single end -->
<!-- product tab start -->
<div class="product-tab theme3 bg-white pt-60 pb-80">
<div class="container">
<div class="product-tab-nav">
<div class="row align-items-center">
<div class="col-12">
<nav class="product-tab-menu single-product">
<ul class="nav nav-pills justify-content-center" id="pills-tab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home"
role="tab" aria-controls="pills-home" aria-selected="true">Description</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile"
role="tab" aria-controls="pills-profile" aria-selected="false">Product Details</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact"
role="tab" aria-controls="pills-contact" aria-selected="false">Reviews</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<!-- product-tab-nav end -->
<div class="row">
<div class="col-12">
<div class="tab-content" id="pills-tabContent">
<!-- first tab-pane -->
<div class="tab-pane fade show active" id="pills-home" role="tabpanel"
aria-labelledby="pills-home-tab">
<div class="single-product-desc">
<p><?php echo $pro_desc; ?></p>
</div>
</div>
<!-- second tab-pane -->
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
<div class="single-product-desc">
<p> <?php echo $pro_desc; ?> </p>
</div>
</div>
<!-- third tab-pane -->
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
<div class="single-product-desc">
<div class="grade-content">
<?php
include('connect.php');
$id = $_GET['id'];
error_reporting(0);
$query = "SELECT * FROM `rating_review` WHERE `prod_id`='".$id."'";
$run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($run)) {
$email = $row["email"];
$rating = $row["rating"];
$review = $row["review"];
$created_at = $row["created_at"];
}
for( $x = 0; $x < 5; $x++ )
{
if( floatval( $rating )-$x >= 1 )
{ echo '<li style="display:inline;"><i class="fa fa-star"></i></li>'; }
elseif( $rating-$x > 0 )
{ echo '<li style="display:inline;"><i class="fa fa-star-half"></i></li>'; }
else
{ echo ''; }
}
?>
<h6 class="sub-title"><?php echo $email; ?></h6>
<p><?php echo $created_at; ?></p>
<h4 class="title"><?php echo $review; ?></h4>
</div>
<hr class="hr">
<div class="grade-content">
<div class="contact-form">
<h3 class="title">Leave a Reply</h3>
<form action="" method="POST">
<div class="form-group">
<label for="name">your name</label>
<input type="text" class="form-control" value="<?php echo $_SESSION['email']; ?>" required="" name="email">
</div>
<div class="form-group">
<div class="rateyo" id="rating"
data-rateyo-rating="4"
data-rateyo-num-stars="5"
data-rateyo-score="3">
</div>
<input type="hidden" name="rating">
</div>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control mb-30" name="review" required=""></textarea>
</div>
<?php if(!isset($_SESSION['email'])){ ?>
<a href="login.php" class="btn theme-btn--dark3 btn--xl mt-5 mt-sm-0 rounded-5">Please login to comment !</a>
<?php } else { ?>
<input type="submit" name="Sreview" value="Submit review" class="">
<?php } ?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- product tab end -->
<!-- new arrival section start -->
<section class="theme3 bg-white pb-80">
<div class="container">
<div class="row">
<div class="col-12">
<div class="section-title text-center mb-30">
<h2 class="title text-dark text-capitalize">You might also like</h2>
<p class="text mt-10">Add Related products to weekly line up
</p>
</div>
</div>
<?php
include('connect.php');
$raw_results = mysqli_query($connect,"SELECT * FROM products LIMIT 4");
if(mysqli_num_rows($raw_results) > 0){ ?>
<div class="row">
<?php while($results = mysqli_fetch_array($raw_results)){ ?>
<div class="col-md-3">
<div class="product-list">
<div class="card product-card">
<div class="card-body p-0">
<div class="media flex-column">
<div class="product-thumbnail position-relative">
<span class="badge badge-danger top-right">New</span>
<a href="single-product.php?id=<?php echo $results['id']; ?>">
<img class="first-img" src="admin/productimgs/<?php echo $results['picture']; ?>"
alt="thumbnail">
</a>
<!-- product links -->
<ul class="product-links d-flex justify-content-center">
<li>
<a href="wishlist.html">
<span data-toggle="tooltip" data-placement="bottom"
title="add to wishlist" class="icon-heart"> </span>
</a>
</li>
<li>
<a href="#" data-toggle="modal" data-target="#quick-view">
<span data-toggle="tooltip" data-placement="bottom"
title="Quick view" class="icon-magnifier"></span>
</a>
</li>
</ul>
<!-- product links end-->
</div>
<div class="media-body">
<div class="product-desc">
<h3 class="title"><a href="single-product.php?id=<?php echo $results['id']; ?>"><?php echo $results['name']; ?></a></h3>
<div class="star-rating">
<span class="ion-ios-star"></span>
<span class="ion-ios-star"></span>
<span class="ion-ios-star"></span>
<span class="ion-ios-star"></span>
<span class="ion-ios-star de-selected"></span>
</div>
<div class="d-flex align-items-center justify-content-between">
<h6 class="product-price">Rs. <?php echo $results['price']; ?></h6>
<form class="form-submit">
<input type="hidden" class="pid" value="<?php echo $results['id']; ?>">
<input type="hidden" class="pname" value="<?php echo $results['name']; ?>">
<input type="hidden" class="pprice" value="<?php echo $results['price']; ?>">
<input type="hidden" class="pimage" value="<?php echo $results['picture']; ?>">
<button id="addItem" class="pro-btn"><i class="icon-basket"></i></button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
</section>
<!-- new arrival section end -->
<!-- new arrival section end -->
<?php include("footer.php"); ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/rateYo/2.3.2/jquery.rateyo.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/rateYo/2.3.2/jquery.rateyo.min.js"></script>
<script type="text/javascript">
$(function () {
$(".rateyo").rateYo({
halfStar: true
});
});
$(function () {
$(".rateyo").rateYo().on("rateyo.change", function (e, data) {
var rating = data.rating;
$(this).parent().find('.score').text('score :'+ $(this).attr('data-rateyo-score'));
$(this).parent().find('.result').text('rating :'+ rating);
$(this).parent().find('input[name=rating]').val(rating); //add rating value to input field
});
});
</script>
<?php
include('connect.php');
$id = $_GET['id'];
if(isset($_POST['Sreview'])){
$prod_id = $id;
$email = $_POST['email'];
$rating = $_POST['rating'];
$review = $_POST['review'];
$sql = "INSERT into rating_review(prod_id,email,rating,review) VALUES('$id','".$_SESSION['email']."','$rating','$review')";
$run = mysqli_query($connect,$sql);
}
?>