source: Innova/Product.php@ 057badc

Last change on this file since 057badc was 057badc, checked in by Vlado 222039 <vlado.popovski@…>, 2 months ago

Adding code

  • Property mode set to 100644
File size: 7.3 KB
Line 
1<?
2 session_start();
3
4require 'connect.php';
5
6
7if (isset($_GET['product_id'])) {
8
9 $param = $_GET['product_id'];
10
11 $stmt = $conn->prepare("SELECT * FROM products WHERE product_id = ?");
12 $stmt->bind_param('i', $param);
13 $stmt->execute();
14 $result = $stmt->get_result();
15
16 if($result->num_rows > 0) {
17
18 $row = $result->fetch_assoc();
19 //foreach ($row as $column => $value) {
20 //echo htmlspecialchars($column) . ": " . htmlspecialchars($value) . "<br>";
21 //}
22
23 $product_id = $row['product_id'];
24 $product_name = $row['name'];
25 $product_price = $row['price'];
26 $product_discount = $row['discount'];
27 $product_inStock = $row['in_stock'];
28 $product_category = $row['category'];
29 $product_description = $row['description'];
30 if($row['image1'] != null) {
31 $first_image = basename(strrchr($row['image1'], '/'));
32 $first_image = str_replace(array("'"), '', $first_image);
33 }
34 if($row['image2'] != null) {
35 $second_image = basename(strrchr($row['image2'], '/'));
36 $second_image = str_replace(array("'"), '', $second_image);
37 }
38 if($row['image3'] != null) {
39 $third_image = basename(strrchr($row['image3'], '/'));
40 $third_image = str_replace(array("'"), '', $third_image);
41 }
42 if($row['image4'] != null) {
43 $fourth_image = basename(strrchr($row['image4'], '/'));
44 $fourth_image = str_replace(array("'"), '', $fourth_image);
45 }
46
47 $brand = $row['brand'];
48 $series = $row['series'];
49 $model_number = $row['model_number'];
50 $weight = $row['weight'];
51 $dimensions = $row['dimensions'];
52 $color = $row['color'];
53 $manufactuer = $row['manufactuer'];
54 $origin = $row['origin'];
55 $firstDate = $row['firstDate'];
56
57 $discountAmount = $product_price * ($product_discount / 100);
58 $newPrice = $product_price - $discountAmount;
59 ?>
60
61
62<!DOCTYPE html>
63<html lang="en">
64<head>
65 <meta charset="UTF-8">
66 <meta name="viewport" content="width=device-width, initial-scale=1.0">
67 <title><?php echo isset($productName) ? htmlspecialchars($productName) : 'Product Page'; ?></title>
68 <!-- css -->
69 <link rel="stylesheet" href="/CSS/Header.css">
70 <link rel="stylesheet" href="/CSS/ProductPage.css">
71 <link rel="stylesheet" href="https://unpkg.com/boxicons@latest/css/boxicons.min.css">
72 <script type="importmap">
73 {
74 "imports": {
75 "three": "./three/build/three.module.js",
76 "three/addons/": "./three/three.js-master/examples/jsm/"
77 }
78 }
79 </script>
80</head>
81<body>
82
83 <?php include './components/Header.html' ?>
84 <section>
85 <div class="pagination">
86 <p>Home > Products > <?php echo $product_category ?> >
87 <?php echo $product_name ?>
88 </p>
89 </div>
90 </section>
91
92 <section class="product-container">
93 <!-- left side -->
94 <div class="img-card">
95 <img src="/UPLOADED_IMAGES/<?php echo $first_image ?>" alt="" id="featured-image">
96 <!-- small img -->
97 <div class="small-Card">
98 <img src="./UPLOADED_IMAGES/<?php echo $first_image?>" alt="" class="small-Img">
99 <img src="./UPLOADED_IMAGES/<?php echo $second_image ?>" alt="" class="small-Img">
100 <img src="./UPLOADED_IMAGES/<?php echo $third_image ?>" alt="" class="small-Img">
101 <img src="./UPLOADED_IMAGES/<?php echo $fourth_image ?>" alt="" class="small-Img">
102 </div>
103 </div>
104 <!-- Right side -->
105 <div class="product-info">
106 <h3><?php echo $product_name ?></h3>
107 <div class="info__pricing">
108 <span class="info__pricing--price">$<?php echo $newPrice ?></span>
109 <?php
110 if($product_discount > 0){
111 echo '<span class="info__pricing--discount">';
112 echo $product_discount."%</span>";
113 echo '<span class="info__pricing--before"><strike>';
114 echo '$'.$product_price."</strike></span>";
115 }
116 ?>
117 </div>
118 <p><?php echo $product_description ?></p>
119 <form class="quantity" action="./Products.php" method="GET">
120 <input type="hidden" name="product_id" value="<?php echo $product_id; ?>">
121 <input type="number" name="quantity" value="1" min="1">
122 <button type="submit" name="submit" value="add-to-cart">Add to Cart</button>
123 </form>
124
125 <div class="isAvailable">
126 <?php
127 if($product_inStock) {
128 echo '<p>На залиха<i class=\'bx bx-check\'></i></p>';
129 }
130 else {
131 echo '<p>На залиха<i class=\'bx bx-x\' ></i></p>';
132 }
133 ?>
134 </div>
135
136 <div>
137 <p>Delivery:</p>
138 <p>Free standard shipping on orders over $35 before tax, plus free returns.</p>
139 <div class="delivery">
140 <p>TYPE</p> <p>HOW LONG</p> <p>HOW MUCH</p>
141 </div>
142 <hr>
143 <div class="delivery">
144 <p>Standard delivery</p>
145 <p>1-4 business days</p>
146 <p>$4.50</p>
147 </div>
148 <hr>
149 <div class="delivery">
150 <p>Express delivery</p>
151 <p>1 business day</p>
152 <p>$10.00</p>
153 </div>
154 <hr>
155 <div class="delivery">
156 <p>Pick up in store</p>
157 <p>1-3 business days</p>
158 <p>Free</p>
159 </div>
160 </div>
161 </div>
162 </section>
163
164 <!-- PRODUCT DESCRIPTION & INFORMATION -->
165 <section style="width: 90%; margin-left: auto; margin-right: auto; max-width: 1150px;">
166 <div class="center-text">
167 <h2>Oпис</h2>
168 </div>
169
170 <div class="table-container">
171 <div class="product-info-first">
172 <table id="first-table" class="product-table">
173 <?php
174
175 $count = 0;
176 $product_details_count = 0;
177
178 foreach($row as $column => $value) {
179
180 if($count > 10) {
181 if(isset($value) && $value != '') {
182 echo '<tr>';
183 echo '<th style="text-transform: capitalize;">'.$column.'</th>';
184 echo '<td>'.$value.'</td>';
185 echo '</tr>';
186 ++$product_details_count;
187 }
188 }
189
190 ++$count;
191 }
192
193 if($product_details_count == 0) {
194 echo '<p style="text-align: center; font-size: 1.25em; margin-bottom: 24px;">Овој продукт нема опис</p>';
195 }
196
197 ?>
198 </table>
199 </div>
200 </div>
201</section>
202
203 <!-- script tags -->
204 <script src="ProductPage.js"></script>
205 </body>
206</html>
207 <?php
208 }
209 else {
210 echo "NE POSTOI OVOJ PRODUCT";
211 }
212}
213else {
214 echo "Parameter 'param' is not passed.";
215}
Note: See TracBrowser for help on using the repository browser.