-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdetails.php
More file actions
390 lines (377 loc) · 23.4 KB
/
Copy pathdetails.php
File metadata and controls
390 lines (377 loc) · 23.4 KB
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
<?php
include('./functions/functions.php');
require"./includes/dbh.inc.php";
?>
<?php
if(isset($_GET['part_det']) || isset($_GET['add_cart']) || isset($_GET['qty'])){
if(isset($_GET['part_det'])){
$productID = $_GET['part_det'];
}
else{
$productID = $_GET['add_cart'];
}
$selQuery = "SELECT * FROM pcpart WHERE pcPartID='$productID'";
$runQuery = mysqli_query($conn, $selQuery);
$row = mysqli_fetch_array($runQuery);
$image = $row['image'];
$desc = $row['partDesc'];
$qty = $row['qty'];
$price = $row['price'];
$partTitle = $row['partTitle'];
$partName = $row['partKeyword'];
$fetchQuery = "SELECT * FROM pcpartcomp WHERE pcPartID='$partName'";
$fetchQuery = mysqli_query($conn, $fetchQuery);
$fetchRow = mysqli_fetch_array($fetchQuery);
$compName = $fetchRow['pcPartComponents'];
}
if (isset($_GET['add_cart'])) {
$userID=$_SESSION['userId'];
$part_qty = $_POST['quantity'];
$p_id = $_GET['add_cart'];
// print($p_id);
if($userID == 0){
header("LOCATION: login.php?login=notlogin");
}
else{
$checkqty = "SELECT * FROM pcpart WHERE pcPartID='$p_id'";
$checkqtypcpart = mysqli_query($conn, $checkqty);
while($qtyrow = mysqli_fetch_array($checkqtypcpart)){
if($qtyrow['qty'] < $part_qty){
header("LOCATION: details.php?part_det=$p_id&outofstock");
}
else{
if($part_qty == 0){
header("LOCATION: details.php?part_det=$p_id&qty=no");
}
else{
$check_product = "SELECT * FROM cart WHERE userID='$userID' AND productid='$p_id';";
$run_product = mysqli_query($conn, $check_product);
if (mysqli_fetch_array($run_product) > 0) {
echo"<script>alert('This product has already added in cart')</script>";
echo"<script>window.open('details.php?part_det=$p_id','_self')</script>";
} else {
$query = "INSERT INTO cart VALUES (null, '$userID', '$p_id','$part_qty');";
$check = mysqli_query($conn, $query);
if($check){
echo"<script>window.open('details.php?part_det='$p_id'','_self')</script>";
}
}
}
}
}
}
}
?>
<?php
if(isset($_GET['pc_det']) || isset($_GET['addpc_cart'])){
if(isset($_GET['pc_det'])){
$productID = $_GET['pc_det'];
}
else{
$productID = $_GET['addpc_cart'];
}
$selQuery = "SELECT * FROM pc_details WHERE pc_id='$productID'";
$runQuery = mysqli_query($conn, $selQuery);
$row = mysqli_fetch_array($runQuery);
$image = $row['pc_image'];
$partTitle = $row['pcName'];
$price = $row['pcPrice'];
}
if (isset($_GET['addpc_cart'])) {
$userID=$_SESSION['userId'];
$p_id = $_GET['addpc_cart'];
if($userID == 0){
header("LOCATION: login.php?login=notlogin");
}
else{
$check_product = "SELECT * FROM pccart WHERE userid='$userID' AND pcid='$p_id';";
$run_product = mysqli_query($conn, $check_product);
if (mysqli_fetch_array($run_product) > 0) {
echo"<script>alert('This product has already added in cart')</script>";
echo"<script>window.open('index.php?pro_id=$p_id','_self')</script>";
} else {
$query = "INSERT INTO pccart VALUES (null, '$p_id', '$userID');";
$check = mysqli_query($conn, $query);
if($check){
echo"<script>window.open('details.php?part_det='$p_id'','_self')</script>";
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.10.2/css/all.css" integrity="sha384-rtJEYb85SiYWgfpCr0jn174XgJTn4rptSOQsMroFBPQSGLdOC5IbubP6lJ35qoM9" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="js/jquery.exzoom.css" >
<link rel="shortcut icon" type="image/png" href="img/favicon.png" >
<title>Computer-Store | Details</title>
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="./customstyle.css">
<style>
.max-width-50{
width: 400px;
}
</style>
</head>
<body>
<div style="position:sticky;top:0px;z-index:1;height:8%;" class="d-flex flex-col w-100 white shadow-sm">
<div class="d-flex jcsb">
<div class="d-flex flex-row">
<div>
<a href="indexcopy.php"><img class="img1" src="img/cpu.png" alt=""></a>
</div>
<div class="hamburger">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
<div class="menu">
<ul class="ls-none active current-item">
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="index.php">Home</a></li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="builds/system-build.php">SystemBuild</a></li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="builds/completed_build.php">CompletedBuild</a></li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="about.php">About</a></li>
<li class="p-1"><a class="pl-1 text-deco-none text-black nav" href="contact.php">Contact</a></li>
</ul>
</div>
<div>
<a class="toggle-nav" href="#">☰</a>
</div>
</div>
<div class="mt-sm">
<?php
loginORnot();
?>
</div>
</div>
</div>
<div class="container acc-container">
<div class="w-min-100">
<div style=" height:45px; font-size:18px;" class="py-sm pl-2 my-1 b-rad-2 shadow-sm white text-left"><a style="color:#28AB87;" class="text-deco-none" href="./index.php">Home</a> > Details > <a href="" style="color:#28AB87;" class="text-deco-none"><?php if(isset($_GET['part_det'])){ echo $compName ;} ?></a><a href="./builds/completed_build.php" style="color:#28AB87;" class="text-deco-none"><?php if(isset($_GET['pc_det']) || isset($_GET['addpc_cart'])){ echo "Completed Builds" ;} ?></a> > <?php echo $partTitle; ?></div>
</div>
<div class=" acc-container">
<div style="width:100%" class="d-flex flex-row md-d-flex md-flex-col">
<div class="d-flex mb-1 jcc">
<div style="max-width:100%;" class="text-left">
<div class="exzoom" id="exzoom">
<div class="exzoom_img_box">
<ul class='exzoom_img_ul'>
<li><img class="max-width-50" src="admin/upload/<?php echo $image ; ?>" alt=""></li>
</ul>
</div>
</div>
</div>
</div>
<div style="width:100%" class="white shadow-md">
<div class=" white pt-1">
<?php
?>
<?php
if(isset($_GET['qty'])){
echo"<div class='text-center' style='color:red;font-size:14px;'>Enter some quantity!</div>";
}
if(isset($_GET['outofstock'])){
echo"<div class='text-center' style='color:red;font-size:14px;'>Out of Stock!</div>";
}
?>
<h3 class=""><b><?php echo $partTitle; ?></b></h3>
</div>
<div class="mx-1 pb-1" style="font-size:18px;">
<p><?php if(isset($_GET['part_det']) || isset($_GET['add_cart'])){ echo "
<div class='text-left p-2'>$desc</div>
<div style='color:gray;font-size:20px;' class='p-sm'><b>MRP: ₹$price</b></div>
<div style='color:gray;font-size:20px;' class=' p-sm'>You Save:<strike>"?><?php echo $price/2; ?><?php echo"</strike></div>
<div style='font-size:20px;' class='p-sm'><b>Quantity:$qty</b></div>
"; }?></p>
<p class="text-left">
<?php
if(isset($_GET['pc_det']) || isset($_GET['addpc_cart'])){
echo"
<div class='pt-1 px-1'>
<h3 class='p-sm' style='background:#28AB87; color:white;'>Products Details</h3>
</div>
<table class='w-100 content-table text-left'>
<tr>
<th class='p-sm'>PC Type</th>
<th>{$row['PC_Type']}</th>
</tr>
<tr>
<th class='p-sm'>Motherboard</th>
<th>{$row['motherboard']}</th>
</tr>
<tr>
<th class='p-sm'>Processor</th>
<th>{$row['processor']}</th>
</tr>
<tr>
<th class='p-sm'>Hard Disk</th>
<th>{$row['hardDisk']}</th>
</tr>
<tr>
<th class='p-sm'>RAM type</th>
<th>{$row['ram_type']}</th>
</tr>
<tr>
<th class='p-sm'>Ram Company</th>
<th>{$row['ram_company']}</th>
</tr>
<tr>
<th class='p-sm'>RAM Capacity</th>
<th>{$row['ram_capacity']}</th>
</tr>
<tr>
<th class='p-sm'>Graphics Card</th>
<th>{$row['graphics_card_type']}</th>
</tr>
<tr>
<th class='p-sm'>Graphics Capacity</th>
<th>{$row['graphics_card']}</th>
</tr>
<tr>
<th class='p-sm'>Monitor</th>
<th>{$row['monitor']}</th>
</tr>
<tr>
<th class='p-sm'>Monitor Display Size(in INCH)</th>
<th>{$row['monitor_display']}''</th>
</tr>
<tr>
<th class='p-sm'>Keyboard Company</th>
<th>{$row['keyboard_company']}</th>
</tr>
<tr>
<th class='p-sm'>Mouse Company</th>
<th>{$row['mouse_company']}</th>
</tr>
<tr>
<th class='p-sm'>Speaker Company</th>
<th>{$row['speakers']}</th>
</tr>
</table>
";
}
?>
</p>
<div class="p-1 aic">
<div class="white p-sm">
<div class="mb-1">
<div class="container">
<h3>Add to cart</h3>
</div>
</div>
<?php
if(isset($_GET['part_det']) || isset($_GET['add_cart']) || isset($_GET['qty'])){
echo'
<div>
<form action="details.php?add_cart='?><?php echo $productID; echo'" method="POST">
<input class="input-field" type="number" name="quantity" placeholder="Enter quantity...">
<div><button style="background:#28AB87; color:white" class="px-1 py-sm mt-1 b-0 b-rad-1 fas fa-cart-plus">Add to cart</button></div>
</form>
</div>
';
}
if(isset($_GET['pc_det']) || isset($_GET['addpc_cart'])){
echo'
<div class="pt-sm">
₹ ';
echo $price;
echo'
</div>
<div class="m-1">
<a href="details.php?addpc_cart='.$productID.'" style="background:#28AB87; color:white" class="text-deco-none p-sm b-rad-1 shadow-md">
<i style="padding-right:10px;color:white;" class="fas fa-cart-plus"></i>
Add to cart
</a>
</div>
';
}
?>
</div>
</div>
</div>
</div>
</div>
<div style="" class="white mt-1 p-1 b-rad-1 shadow-sm">
<b> Products You may also like</b>
</div>
<div class="mt-1">
<div class="d-flex flex-wrap jcsa">
<?php
if(isset($_GET['part_det'])){
$query = "SELECT * FROM pcpart ORDER BY RAND() LIMIT 0,4";
$check = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($check)) {
$partname = $row['partKeyword'];
$partID = $row['pcPartID'];
echo "
<div style='width:220px;' class='shadow-md white b-rad-2 card-hover'>
<a style='color:#28AB87' class='text-deco-none' href='details.php?part_det=".$partID."'>
<div class='single-img'>
<img class='img2 mt-1' src='admin/upload/".$row['image']."'/>
</div>
<div style='font-size:20px;' class='text-center'>
<h4 class='m-1'>{$row['partTitle']}</h4></a><br>
<div class='text-primary'>
<div class='m-1 text-black'><b>₹{$row['price']}/-</b></div>
</div>
<div class='mx-sm'>
<div class='mb-3 mt-2 md-mt-2 d-flex jcsa md-flex-col'>
<div class='md-mb-2'><a style='background:#28AB87' class='button-field text-deco-none shadow-md' href='details.php?part_det={$partID}'>Details</a></div>
<div><a style='background:#28AB87' class='button-field text-deco-none shadow-md' href='index.php?add_cart={$partID}'>AddToCart</a></div>
</div>
</div>
</div>
</div>
";
}
}
?>
<?php
if(isset($_GET['pc_det'])){
$query = "SELECT * FROM pc_details ORDER BY RAND() LIMIT 0,4;";
$check = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($check)) {
$p_id = $row['pc_id'];
echo "
<div style='width:240px;' class='shadow-md responsive-card text-center white m-1 p-1 b-rad-2 card-hover'>
<a style='color:#28AB87' class='text-deco-none' href='details.php?pc_det=".$p_id."'>
<div class='single-img'>
<img class='img2 mt-1' src='./admin/upload/".$row['pc_image']."'/><br>
</div>
<h3 class='m-1'>{$row['pcName']}</h3></a>
<div style='font-size:24px;' class='text-black p-1'>
<b>₹ {$row['pcPrice']}</b>
</div>
<div class='my-1'>
<a style='background:#28AB87' class='button-field text-deco-none shadow-md' href='details.php?pc_det={$p_id}'>Details<a>
<a style='background:#28AB87' class='button-field text-deco-none shadow-md' href='index.php?addpc_cart={$p_id}'>Add to cart<a></div>
</div>"
;}
}
?>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="js/jquery.exzoom.js"></script>
<script>
$(function(){
$("#exzoom").exzoom({
"autoPlay":true,
"navWidth": 60,
"navHeight": 60,
"navItemNum": 5,
"navItemMargin": 7,
"navBorder": 1,
"autoPlayTimeout": 2000
});
});
</script>
<?php
require"footer.php";
?>