-
Notifications
You must be signed in to change notification settings - Fork 1
/
product.php
775 lines (710 loc) · 37 KB
/
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
<?php require_once('header.php'); ?>
<?php
if(!isset($_REQUEST['id'])) {
header('location: index.php');
exit;
} else {
// Check the id is valid or not
$statement = $pdo->prepare("SELECT * FROM tbl_product WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$total = $statement->rowCount();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
if( $total == 0 ) {
header('location: index.php');
exit;
}
}
foreach($result as $row) {
$p_name = $row['p_name'];
$p_old_price = $row['p_old_price'];
$p_current_price = $row['p_current_price'];
$p_qty = $row['p_qty'];
$p_featured_photo = $row['p_featured_photo'];
$p_description = $row['p_description'];
$p_short_description = $row['p_short_description'];
$p_feature = $row['p_feature'];
$p_condition = $row['p_condition'];
$p_return_policy = $row['p_return_policy'];
$p_total_view = $row['p_total_view'];
$p_is_featured = $row['p_is_featured'];
$p_is_active = $row['p_is_active'];
$ecat_id = $row['ecat_id'];
}
// Getting all categories name for breadcrumb
$statement = $pdo->prepare("SELECT
t1.ecat_id,
t1.ecat_name,
t1.mcat_id,
t2.mcat_id,
t2.mcat_name,
t2.tcat_id,
t3.tcat_id,
t3.tcat_name
FROM tbl_end_category t1
JOIN tbl_mid_category t2
ON t1.mcat_id = t2.mcat_id
JOIN tbl_top_category t3
ON t2.tcat_id = t3.tcat_id
WHERE t1.ecat_id=?");
$statement->execute(array($ecat_id));
$total = $statement->rowCount();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$ecat_name = $row['ecat_name'];
$mcat_id = $row['mcat_id'];
$mcat_name = $row['mcat_name'];
$tcat_id = $row['tcat_id'];
$tcat_name = $row['tcat_name'];
}
$p_total_view = $p_total_view + 1;
$statement = $pdo->prepare("UPDATE tbl_product SET p_total_view=? WHERE p_id=?");
$statement->execute(array($p_total_view,$_REQUEST['id']));
$statement = $pdo->prepare("SELECT * FROM tbl_product_size WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$size[] = $row['size_id'];
}
$statement = $pdo->prepare("SELECT * FROM tbl_product_color WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$color[] = $row['color_id'];
}
if(isset($_POST['form_review'])) {
$statement = $pdo->prepare("SELECT * FROM tbl_rating WHERE p_id=? AND cust_id=?");
$statement->execute(array($_REQUEST['id'],$_SESSION['customer']['cust_id']));
$total = $statement->rowCount();
if($total) {
$error_message = LANG_VALUE_68;
} else {
$statement = $pdo->prepare("INSERT INTO tbl_rating (p_id,cust_id,comment,rating) VALUES (?,?,?,?)");
$statement->execute(array($_REQUEST['id'],$_SESSION['customer']['cust_id'],$_POST['comment'],$_POST['rating']));
$success_message = LANG_VALUE_163;
}
}
// Getting the average rating for this product
$t_rating = 0;
$statement = $pdo->prepare("SELECT * FROM tbl_rating WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$tot_rating = $statement->rowCount();
if($tot_rating == 0) {
$avg_rating = 0;
} else {
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$t_rating = $t_rating + $row['rating'];
}
$avg_rating = $t_rating / $tot_rating;
}
if(isset($_POST['form_add_to_cart'])) {
// getting the currect stock of this product
$statement = $pdo->prepare("SELECT * FROM tbl_product WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$current_p_qty = $row['p_qty'];
}
if($_POST['p_qty'] > $current_p_qty):
$temp_msg = 'Sorry! There are only '.$current_p_qty.' item(s) in stock';
?>
<script type="text/javascript">alert('<?php echo $temp_msg; ?>');</script>
<?php
else:
if(isset($_SESSION['cart_p_id']))
{
$arr_cart_p_id = array();
$arr_cart_size_id = array();
$arr_cart_color_id = array();
$arr_cart_p_qty = array();
$arr_cart_p_current_price = array();
$i=0;
foreach($_SESSION['cart_p_id'] as $key => $value)
{
$i++;
$arr_cart_p_id[$i] = $value;
}
$i=0;
foreach($_SESSION['cart_size_id'] as $key => $value)
{
$i++;
$arr_cart_size_id[$i] = $value;
}
$i=0;
foreach($_SESSION['cart_color_id'] as $key => $value)
{
$i++;
$arr_cart_color_id[$i] = $value;
}
$added = 0;
if(!isset($_POST['size_id'])) {
$size_id = 0;
} else {
$size_id = $_POST['size_id'];
}
if(!isset($_POST['color_id'])) {
$color_id = 0;
} else {
$color_id = $_POST['color_id'];
}
for($i=1;$i<=count($arr_cart_p_id);$i++) {
if( ($arr_cart_p_id[$i]==$_REQUEST['id']) && ($arr_cart_size_id[$i]==$size_id) && ($arr_cart_color_id[$i]==$color_id) ) {
$added = 1;
break;
}
}
if($added == 1) {
$error_message1 = 'This product is already added to the shopping cart.';
} else {
$i=0;
foreach($_SESSION['cart_p_id'] as $key => $res)
{
$i++;
}
$new_key = $i+1;
if(isset($_POST['size_id'])) {
$size_id = $_POST['size_id'];
$statement = $pdo->prepare("SELECT * FROM tbl_size WHERE size_id=?");
$statement->execute(array($size_id));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$size_name = $row['size_name'];
}
} else {
$size_id = 0;
$size_name = '';
}
if(isset($_POST['color_id'])) {
$color_id = $_POST['color_id'];
$statement = $pdo->prepare("SELECT * FROM tbl_color WHERE color_id=?");
$statement->execute(array($color_id));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$color_name = $row['color_name'];
}
} else {
$color_id = 0;
$color_name = '';
}
$_SESSION['cart_p_id'][$new_key] = $_REQUEST['id'];
$_SESSION['cart_size_id'][$new_key] = $size_id;
$_SESSION['cart_size_name'][$new_key] = $size_name;
$_SESSION['cart_color_id'][$new_key] = $color_id;
$_SESSION['cart_color_name'][$new_key] = $color_name;
$_SESSION['cart_p_qty'][$new_key] = $_POST['p_qty'];
$_SESSION['cart_p_current_price'][$new_key] = $_POST['p_current_price'];
$_SESSION['cart_p_name'][$new_key] = $_POST['p_name'];
$_SESSION['cart_p_featured_photo'][$new_key] = $_POST['p_featured_photo'];
$success_message1 = 'Product is added to the cart successfully!';
}
}
else
{
if(isset($_POST['size_id'])) {
$size_id = $_POST['size_id'];
$statement = $pdo->prepare("SELECT * FROM tbl_size WHERE size_id=?");
$statement->execute(array($size_id));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$size_name = $row['size_name'];
}
} else {
$size_id = 0;
$size_name = '';
}
if(isset($_POST['color_id'])) {
$color_id = $_POST['color_id'];
$statement = $pdo->prepare("SELECT * FROM tbl_color WHERE color_id=?");
$statement->execute(array($color_id));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$color_name = $row['color_name'];
}
} else {
$color_id = 0;
$color_name = '';
}
$_SESSION['cart_p_id'][1] = $_REQUEST['id'];
$_SESSION['cart_size_id'][1] = $size_id;
$_SESSION['cart_size_name'][1] = $size_name;
$_SESSION['cart_color_id'][1] = $color_id;
$_SESSION['cart_color_name'][1] = $color_name;
$_SESSION['cart_p_qty'][1] = $_POST['p_qty'];
$_SESSION['cart_p_current_price'][1] = $_POST['p_current_price'];
$_SESSION['cart_p_name'][1] = $_POST['p_name'];
$_SESSION['cart_p_featured_photo'][1] = $_POST['p_featured_photo'];
$success_message1 = 'Product is added to the cart successfully!';
}
endif;
}
?>
<?php
if($error_message1 != '') {
echo "<script>alert('".$error_message1."')</script>";
}
if($success_message1 != '') {
echo "<script>alert('".$success_message1."')</script>";
header('location: product.php?id='.$_REQUEST['id']);
}
?>
<div class="page">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="breadcrumb mb_30">
<ul>
<li><a href="<?php echo BASE_URL; ?>">Home</a></li>
<li>></li>
<li><a href="<?php echo BASE_URL.'product-category.php?id='.$tcat_id.'&type=top-category' ?>"><?php echo $tcat_name; ?></a></li>
<li>></li>
<li><a href="<?php echo BASE_URL.'product-category.php?id='.$mcat_id.'&type=mid-category' ?>"><?php echo $mcat_name; ?></a></li>
<li>></li>
<li><a href="<?php echo BASE_URL.'product-category.php?id='.$ecat_id.'&type=end-category' ?>"><?php echo $ecat_name; ?></a></li>
<li>></li>
<li><?php echo $p_name; ?></li>
</ul>
</div>
<div class="product">
<div class="row">
<div class="col-md-5">
<ul class="prod-slider">
<li style="background-image: url(assets/uploads/<?php echo $p_featured_photo; ?>);">
<a class="popup" href="assets/uploads/<?php echo $p_featured_photo; ?>"></a>
</li>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_product_photo WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<li style="background-image: url(assets/uploads/product_photos/<?php echo $row['photo']; ?>);">
<a class="popup" href="assets/uploads/product_photos/<?php echo $row['photo']; ?>"></a>
</li>
<?php
}
?>
</ul>
<div id="prod-pager">
<a data-slide-index="0" href=""><div class="prod-pager-thumb" style="background-image: url(assets/uploads/<?php echo $p_featured_photo; ?>"></div></a>
<?php
$i=1;
$statement = $pdo->prepare("SELECT * FROM tbl_product_photo WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<a data-slide-index="<?php echo $i; ?>" href=""><div class="prod-pager-thumb" style="background-image: url(assets/uploads/product_photos/<?php echo $row['photo']; ?>"></div></a>
<?php
$i++;
}
?>
</div>
</div>
<div class="col-md-7">
<div class="p-title"><h2><?php echo $p_name; ?></h2></div>
<div class="p-review">
<div class="rating">
<?php
if($avg_rating == 0) {
echo '';
}
elseif($avg_rating == 1.5) {
echo '
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
';
}
elseif($avg_rating == 2.5) {
echo '
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
';
}
elseif($avg_rating == 3.5) {
echo '
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o"></i>
';
}
elseif($avg_rating == 4.5) {
echo '
<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-half-o"></i>
';
}
else {
for($i=1;$i<=5;$i++) {
?>
<?php if($i>$avg_rating): ?>
<i class="fa fa-star-o"></i>
<?php else: ?>
<i class="fa fa-star"></i>
<?php endif; ?>
<?php
}
}
?>
</div>
</div>
<div class="p-short-des">
<p>
<?php echo $p_short_description; ?>
</p>
</div>
<form action="" method="post">
<div class="p-quantity">
<div class="row">
<?php if(isset($size)): ?>
<div class="col-md-12 mb_20">
<?php echo LANG_VALUE_52; ?> <br>
<select name="size_id" class="form-control select2" style="width:auto;">
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_size");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
if(in_array($row['size_id'],$size)) {
?>
<option value="<?php echo $row['size_id']; ?>"><?php echo $row['size_name']; ?></option>
<?php
}
}
?>
</select>
</div>
<?php endif; ?>
<?php if(isset($color)): ?>
<div class="col-md-12">
<?php echo LANG_VALUE_53; ?> <br>
<select name="color_id" class="form-control select2" style="width:auto;">
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_color");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
if(in_array($row['color_id'],$color)) {
?>
<option value="<?php echo $row['color_id']; ?>"><?php echo $row['color_name']; ?></option>
<?php
}
}
?>
</select>
</div>
<?php endif; ?>
</div>
</div>
<div class="p-price">
<span style="font-size:14px;"><?php echo LANG_VALUE_54; ?></span><br>
<span>
<?php if($p_old_price!=''): ?>
<del><?php echo LANG_VALUE_1; ?><?php echo $p_old_price; ?></del>
<?php endif; ?>
<?php echo LANG_VALUE_1; ?><?php echo $p_current_price; ?>
</span>
</div>
<input type="hidden" name="p_current_price" value="<?php echo $p_current_price; ?>">
<input type="hidden" name="p_name" value="<?php echo $p_name; ?>">
<input type="hidden" name="p_featured_photo" value="<?php echo $p_featured_photo; ?>">
<div class="p-quantity">
<?php echo LANG_VALUE_55; ?> <br>
<input type="number" class="input-text qty" step="1" min="1" max="" name="p_qty" value="1" title="Qty" size="4" pattern="[0-9]*" inputmode="numeric">
</div>
<div class="btn-cart btn-cart1">
<input type="submit" value="<?php echo LANG_VALUE_154; ?>" name="form_add_to_cart">
</div>
</form>
<div class="share">
<?php echo LANG_VALUE_58; ?> <br>
<div class="sharethis-inline-share-buttons"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#description" aria-controls="description" role="tab" data-toggle="tab"><?php echo LANG_VALUE_59; ?></a></li>
<li role="presentation"><a href="#feature" aria-controls="feature" role="tab" data-toggle="tab"><?php echo LANG_VALUE_60; ?></a></li>
<li role="presentation"><a href="#condition" aria-controls="condition" role="tab" data-toggle="tab"><?php echo LANG_VALUE_61; ?></a></li>
<li role="presentation"><a href="#return_policy" aria-controls="return_policy" role="tab" data-toggle="tab"><?php echo LANG_VALUE_62; ?></a></li>
<li role="presentation"><a href="#review" aria-controls="review" role="tab" data-toggle="tab"><?php echo LANG_VALUE_63; ?></a></li>
<li><a target="_blank" href="/Chatbox/index.php">Conversation</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="description" style="margin-top: -30px;">
<p>
<?php
if($p_description == '') {
echo LANG_VALUE_70;
} else {
echo $p_description;
}
?>
</p>
</div>
<div role="tabpanel" class="tab-pane" id="feature" style="margin-top: -30px;">
<p>
<?php
if($p_feature == '') {
echo LANG_VALUE_71;
} else {
echo $p_feature;
}
?>
</p>
</div>
<div role="tabpanel" class="tab-pane" id="condition" style="margin-top: -30px;">
<p>
<?php
if($p_condition == '') {
echo LANG_VALUE_72;
} else {
echo $p_condition;
}
?>
</p>
</div>
<div role="tabpanel" class="tab-pane" id="return_policy" style="margin-top: -30px;">
<p>
<?php
if($p_return_policy == '') {
echo LANG_VALUE_73;
} else {
echo $p_return_policy;
}
?>
</p>
</div>
<div role="tabpanel" class="tab-pane" id="review" style="margin-top: -30px;">
<div class="review-form">
<?php
$statement = $pdo->prepare("SELECT *
FROM tbl_rating t1
JOIN tbl_customer t2
ON t1.cust_id = t2.cust_id
WHERE t1.p_id=?");
$statement->execute(array($_REQUEST['id']));
$total = $statement->rowCount();
?>
<h2><?php echo LANG_VALUE_63; ?> (<?php echo $total; ?>)</h2>
<?php
if($total) {
$j=0;
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$j++;
?>
<div class="mb_10"><b><u><?php echo LANG_VALUE_64; ?> <?php echo $j; ?></u></b></div>
<table class="table table-bordered">
<tr>
<th style="width:170px;"><?php echo LANG_VALUE_75; ?></th>
<td><?php echo $row['cust_name']; ?></td>
</tr>
<tr>
<th><?php echo LANG_VALUE_76; ?></th>
<td><?php echo $row['comment']; ?></td>
</tr>
<tr>
<th><?php echo LANG_VALUE_78; ?></th>
<td>
<div class="rating">
<?php
for($i=1;$i<=5;$i++) {
?>
<?php if($i>$row['rating']): ?>
<i class="fa fa-star-o"></i>
<?php else: ?>
<i class="fa fa-star"></i>
<?php endif; ?>
<?php
}
?>
</div>
</td>
</tr>
</table>
<?php
}
} else {
echo LANG_VALUE_74;
}
?>
<h2><?php echo LANG_VALUE_65; ?></h2>
<?php
if($error_message != '') {
echo "<script>alert('".$error_message."')</script>";
}
if($success_message != '') {
echo "<script>alert('".$success_message."')</script>";
}
?>
<?php if(isset($_SESSION['customer'])): ?>
<?php
$statement = $pdo->prepare("SELECT *
FROM tbl_rating
WHERE p_id=? AND cust_id=?");
$statement->execute(array($_REQUEST['id'],$_SESSION['customer']['cust_id']));
$total = $statement->rowCount();
?>
<?php if($total==0): ?>
<form action="" method="post">
<div class="rating-section">
<input type="radio" name="rating" class="rating" value="1" checked>
<input type="radio" name="rating" class="rating" value="2" checked>
<input type="radio" name="rating" class="rating" value="3" checked>
<input type="radio" name="rating" class="rating" value="4" checked>
<input type="radio" name="rating" class="rating" value="5" checked>
</div>
<div class="form-group">
<textarea name="comment" class="form-control" cols="30" rows="10" placeholder="Write your comment (optional)" style="height:100px;"></textarea>
</div>
<input type="submit" class="btn btn-default" name="form_review" value="<?php echo LANG_VALUE_67; ?>">
</form>
<?php else: ?>
<span style="color:red;"><?php echo LANG_VALUE_68; ?></span>
<?php endif; ?>
<?php else: ?>
<p class="error">
<?php echo LANG_VALUE_69; ?> <br>
<a href="login.php" style="color:red;text-decoration: underline;"><?php echo LANG_VALUE_9; ?></a>
</p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="product bg-gray pt_70 pb_70">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="headline">
<h2><?php echo LANG_VALUE_155; ?></h2>
<h3><?php echo LANG_VALUE_156; ?></h3>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="product-carousel">
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_product WHERE ecat_id=? AND p_id!=?");
$statement->execute(array($ecat_id,$_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<div class="item">
<div class="thumb">
<div class="photo" style="background-image:url(assets/uploads/<?php echo $row['p_featured_photo']; ?>);"></div>
<div class="overlay"></div>
</div>
<div class="text">
<h3><a href="product.php?id=<?php echo $row['p_id']; ?>"><?php echo $row['p_name']; ?></a></h3>
<h4>
<?php echo LANG_VALUE_1; ?><?php echo $row['p_current_price']; ?>
<?php if($row['p_old_price'] != ''): ?>
<del>
<?php echo LANG_VALUE_1; ?><?php echo $row['p_old_price']; ?>
</del>
<?php endif; ?>
</h4>
<div class="rating">
<?php
$t_rating = 0;
$statement1 = $pdo->prepare("SELECT * FROM tbl_rating WHERE p_id=?");
$statement1->execute(array($row['p_id']));
$tot_rating = $statement1->rowCount();
if($tot_rating == 0) {
$avg_rating = 0;
} else {
$result1 = $statement1->fetchAll(PDO::FETCH_ASSOC);
foreach ($result1 as $row1) {
$t_rating = $t_rating + $row1['rating'];
}
$avg_rating = $t_rating / $tot_rating;
}
?>
<?php
if($avg_rating == 0) {
echo '';
}
elseif($avg_rating == 1.5) {
echo '
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
';
}
elseif($avg_rating == 2.5) {
echo '
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o"></i>
<i class="fa fa-star-o"></i>
';
}
elseif($avg_rating == 3.5) {
echo '
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-half-o"></i>
<i class="fa fa-star-o"></i>
';
}
elseif($avg_rating == 4.5) {
echo '
<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-half-o"></i>
';
}
else {
for($i=1;$i<=5;$i++) {
?>
<?php if($i>$avg_rating): ?>
<i class="fa fa-star-o"></i>
<?php else: ?>
<i class="fa fa-star"></i>
<?php endif; ?>
<?php
}
}
?>
</div>
<p><a href="product.php?id=<?php echo $row['p_id']; ?>"><?php echo LANG_VALUE_154; ?></a></p>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
<?php require_once('footer.php'); ?>