-
Notifications
You must be signed in to change notification settings - Fork 0
/
single_product.php
152 lines (126 loc) · 5.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
<?php
include('config/db.php');
?>
<?php
if (isset($_GET)) {
if (isset($_GET['id'])) {
$productId = trim($_GET['id']);
$query = "SELECT * FROM t_product WHERE p_id=:productId";
$stmt = $pdo->prepare($query);
$exec = $stmt->execute(['productId' => $productId]);
}
if ($exec) {
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'];
$isAvailable = $isAvailable ? "Available" : "Not Available";
?>
<?php
$page_title = $name;
include('includes/head.php');
?>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-8">
<div class="position-sticky" style="top: 100px">
<h1 class="my-4 text-uppercase" style="top: 200px"><?php echo $name ?>
<small> By </small>
<small class="text-primary"> <?php echo $brand ?></small>
</h1>
<img class="img-fluid "
src="assets/img/products/<?php echo $img ?>" alt="">
</div>
</div>
<div class="col-md-12 col-lg-4">
<h3 class="my-3 text-uppercase text-secondary"><?php echo $name ?></h3>
<p><?php echo $desc ?></p>
<details>
<summary class="my-3 text-capitalize text-secondary">Product Details</summary>
<ul>
<li>Brand:
<span class="text-primary"><?php echo $brand ?></span>
</li>
<li>Color:
<span class="text-primary"><?php echo $color ?></span>
</li>
<li>Size:
<span class="text-primary"><?php echo $size ?></span>
</li>
<li>Weight:
<span class="text-primary"><?php echo $weight ?></span>
</li>
<li>Status:
<span class="text-primary"><?php echo $isAvailable ?></span>
</li>
</ul>
</details>
<?php
echo " <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>
<!-- /.row -->
<?php
}
}
}
?>
<!-- Related Projects Row -->
<h3 class="my-4">Related Products</h3>
<div class="row">
<?php
$query = "SELECT * FROM t_product WHERE p_category=:category";
$stmt = $pdo->prepare($query);
$exec = $stmt->execute(['category' => $category]);
if ($exec) {
$counter = 0;
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'];
$counter++;
?>
<div class="col-md-3 col-sm-6 mb-4 d-flex flex-column align-items-center justify-content-center">
<a href="single_product.php?id=<?php echo $id ?>">
<img class="img-fluid" src="assets/img/products/<?php echo $img ?>" alt="<?php echo $name ?>"
style="height: 300px">
</a>
<a class="btn btn-link mt-1 " href="single_product.php?id=<?php echo $id ?>"><?php echo $name ?></a>
</div>
<?php
if ($counter >= 4) {
break;
}
}
}
?>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<?php
include('includes/tail.php');
?>