-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
69 lines (55 loc) · 2.05 KB
/
cart.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
<?php
// for error logging incase of fail
error_reporting(E_ALL);
ini_set('display_errors', 1);
// loads the dynamic header
$page_name="cart";
require_once('inc/header.php');
// loading database
require_once('inc/lib.php');
connect();
?>
<body>
<!-- main content of the page -->
<div id="back_gradient"></div>
<div id="cart" class="cart">
<div class = "gallery-container">
<?php
$unique_ids = array();
foreach($_SESSION['basket'] as $product_id) {
if(! in_array($product_id,$unique_ids)){
$unique_ids[] = $product_id;
$sql = "SELECT * FROM images WHERE id = $product_id";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
echo '<div class = "cart-container">';
echo '<div class = "image-container">';
echo '<img src = "images/artwork/' . $product_id . '.png" alt = "' . $row["title"] . '">';
echo '</div>';
echo '<div class = "info-container">';
echo '<h1>' . $row["title"] . '</h1>' ;
echo '<pre>Year : ' . (($row["year"] === NULL) ? "Unkown" : $row["year"]) . '</pre>';
echo '<pre>Medium : ' . (($row["medium"] === NULL) ? "Unkown" : $row["medium"]) . '</pre>';
echo '<pre>Size : ' . (($row["size"] === NULL) ? "Unkown" : "W" . $row["width"] ."cm x H". $row["height"] . "cm") . '</pre>';
echo '<pre>Sold : ' . $row["sold"] .'</pre>';
echo '<pre>In Basket : ' . get_basket_count($row["id"]) .'</pre>';
echo '<div class="button-container">';
echo '<form method="post" action="">';
echo '<input type="hidden" name="id" value="' . $row["id"] . '">';
echo '<button type="submit" name="add_to_cart" id="button_good">Add another</button>';
echo '</form>';
echo '<form method="post" action="">';
echo '<input type="hidden" name="id" value="' . $row["id"] . '">';
echo '<button type="submit" name="remove_from_cart" id="button_bad">Remove one</button>';
echo '</form>';
echo '</div>';
echo '</div>';
echo '</div>';
}
}
?>
</div>
</div>
<?php include 'inc/footer.php'; ?>
</body>
</html>