-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheducational.php
73 lines (63 loc) · 2.84 KB
/
educational.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
<?php
session_start();
include('includes/catalog.php');
if (!isset($_SESSION['cart'])) {
$_SESSION['cart'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['product_id'])) {
$product_id = $_POST['product_id'];
$_SESSION['cart'][] = $product_id;
}
$cartItemCount = count($_SESSION['cart']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Educational Books</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<a href="index.php" class="btn btn-primary" style="position: absolute; top: 10px; left: 100px;">Home</a>
<a href="shopping_cart.php" class="btn btn-primary" style="position: absolute; top: 10px; right: 100px;">Shopping Cart</a>
<h1 class="text-center">Educational Books</h1>
<p><?php echo "Total Number of Items in cart: $cartItemCount"; ?></p>
<?php if (isset($_SESSION['cart_message'])): ?>
<p><?php echo $_SESSION['cart_message']; ?></p>
<?php unset($_SESSION['cart_message']); ?>
<?php endif; ?>
<ul class="list-group">
<?php if (isset($_SESSION['cart_message'])): ?>
<p><?php echo $_SESSION['cart_message']; ?></p>
<?php unset($_SESSION['cart_message']); ?>
<?php endif; ?>
<?php foreach ($catalog['educational'] as $book): ?>
<li class="list-group-item">
<div class="row">
<div class="col-md-3">
<img src="images/<?php echo $book['cover_image']; ?>" alt="<?php echo $book['title']; ?>" class="img-fluid">
</div>
<div class="col-md-9">
<h2><?php echo $book['title']; ?></h2>
<p>Author: <?php echo $book['author']; ?></p>
<p>Price: $<?php echo $book['price']; ?></p>
<p>ISBN: <?php echo $book['isbn']; ?></p>
<p>Publication Year: <?php echo $book['year']; ?></p>
<p>Genres: <?php echo implode(', ', $book['genres']); ?></p>
</div>
<div class="col-md-3">
<form action="educational.php" method="post">
<input type="hidden" name="product_id" value="<?php echo $book['isbn']; ?>">
<input type="hidden" name="genre" value="educational">
<input type="submit" value="Buy" class="btn btn-dark">
</form>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php include('includes/footer.php'); ?>
</body>
</html>