-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop.php
154 lines (130 loc) · 6.72 KB
/
shop.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
<?php
require('config/db.php');
?>
<!-- Bootstrap core CSS -->
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome-->
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<!--My Style-->
<link rel="stylesheet" href="assets/css/shop.css">
<?php
$page_title = "Shop";
include('includes/navigation.php');
?>
<link rel="stylesheet" href="assets/css/neon.css">
<!-- Page Content -->
<div class="container" style="text-align: left; max-width: 1500px">
<div class="row">
<div class="col-lg-3">
<?php
include('includes/neon_shop_name.php');
?>
<div class="list-group ">
<a href="results.php?cat=laptop" class="list-group-item">Laptop</a>
<a href="results.php?cat=mobile" class="list-group-item">Phone</a>
<a href="results.php?cat=tablet" class="list-group-item">Tablet</a>
<a href="results.php?cat=smartWatch" class="list-group-item">Smart Watch</a>
</div>
</div>
<!-- /.col-lg-3 -->
<div class="col-lg-9">
<div id="carouselExampleIndicators" class="carousel slide my-4" data-ride="carousel" style="max-width: 900px">
<ol class="carousel-indicators">
<?php
$count = 6;
for ($i = 0; $i < $count; $i++) {
echo "<li data-target='#carouselExampleIndicators' data-slide-to='$i'></li>";
}
?>
</ol>
<div class="carousel-inner" role="listbox">
<?php
$car_query = "SELECT * FROM t_product";
$car_stmt = $pdo->prepare($car_query);
$car_stmt->execute();
while (($car_row = $car_stmt->fetch()) && ($count > 0)) {
$name = $car_row['p_name'];
$category = $car_row['p_category'];
$img = $car_row['p_image'];
echo "<div class='carousel-item'>
<img class='d-block img-fluid w-100' src='assets/img/products/{$img}' alt='$name' style='height: 502px;'>
</div>";
$count--;
}
?>
<div class="carousel-item active">
<img class="d-block img-fluid" src="assets/img/products/1.jpg" alt="First slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div class="row mt-5">
<?php
$query = "SELECT * FROM t_product";
$stmt = $pdo->prepare($query);
$stmt->execute();
while ($productRow = $stmt->fetch()) {
$id = $productRow['p_id'];
$name = $productRow['p_name'];
$category = $productRow['p_category'];
$img = $productRow['p_image'];
$price = $productRow['p_price'];
$desc = $productRow['p_description'];
$color = $productRow['p_color'];
$size = $productRow['p_size'];
$isAvailable = $productRow['p_isAvailable'];
$count = $productRow['p_count'];
$weight = $productRow['p_weight'];
$brand = $productRow['p_brand'];
if (strlen($name) > 12) {
$name = substr($name, 0, 12) . " ...";
} else {
$name = substr($name, 0, 12);
}
$desc = substr($desc, 0, 150);
echo " <div class='col-lg-4 col-md-6 mb-4'>
<div class='card w-100' style='max-height: 650px'>
<a href='single_product.php?id={$id}'>
<img class='card-img-top' src='assets/img/products/{$img}' alt='$name' style='height: 300px'>
</a>
<div class='card-body'>
<h4 class='card-title text-nowrap'>
<a href='single_product.php?id={$id}'>$name</a>
</h4>
<h5>$$price</h5>
<p class='card-text font-weight-lighter'>$desc ...
<a href='single_product.php?id={$id}' class='btn btn-link'>Read more</a>
</p>
</div>
<div class='card-footer d-flex justify-content-between'>
<small class='text-muted align-self-end'>★ ★ ★ ★ ☆</small>
<form action='user/cart.php' method='post' class='align-self-end mb-0'>
<input type='hidden' name='product_id' value='{$id}'>
<button class='btn btn-outline-primary ' type='submit' name='addToCartSubmit'>Add to Cart <i class='fa fa-shopping-cart'></i></button>
</form>
</div>
</div>
</div>";
}
?>
</div>
<!-- /.row -->
</div>
<!-- /.col-lg-9 -->
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<?php
include("includes/home/footer.php");
?>
<?php
include("includes/tail.php");
?>