-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook.php
78 lines (70 loc) · 2.47 KB
/
book.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
<?php
session_start();
$book_isbn = $_GET['bookisbn'];
require_once "./functions/database_functions.php";
$conn = db_connect();
$query = "SELECT * FROM books WHERE book_isbn = '$book_isbn'";
$result = mysqli_query($conn, $query);
if (!$result) {
$_SESSION["errorArray"]["retrieveFailed"] = "Cannot Retrieve Data";
header("Location : nothingFound.php");
exit;
}
$row = mysqli_fetch_assoc($result);
if (!$row) {
$_SESSION["errorArray"]["emptyBooks"] = "There Are No Books in the Database";
header("Location : nothingFound.php");
exit;
}
$title = $row['book_title'];
require "./template/header.php";
?>
<p class="lead" style="margin: 25px 0"><a href="books.php">Books</a> <span
class="glyphicon glyphicon-arrow-right"></span> <?php echo $row['book_title']; ?></p>
<div class="row">
<div class="col-md-3 text-center">
<img class="img-responsive img-thumbnail book-hover" alt="the book image"
src="./assets/img/<?php echo $row['book_image']; ?>">
</div>
<div class="col-md-6">
<h4>Book Description</h4>
<p><?php echo $row['book_descr']; ?></p><br>
<h4>Book Details</h4>
<table class="table">
<?php foreach ($row as $key => $value) {
if ($key == "book_descr" || $key == "book_image" || $key == "publisherid" || $key == "book_title") {
continue;
}
switch ($key) {
case "book_isbn":
$key = "ISBN";
break;
case "book_title":
$key = "Title";
break;
case "book_author":
$key = "Author";
break;
case "book_price":
$key = "Price";
break;
}
?>
<tr>
<td><?php echo $key; ?></td>
<td><?php echo $value; ?></td>
</tr>
<?php
}
if (isset($conn)) {
mysqli_close($conn);
}
?>
</table>
<form method="post" action="cart.php">
<input type="hidden" name="bookisbn" value="<?php echo $book_isbn; ?>">
<input type="submit" value="Purchase / Add to cart" name="cart" class="btn btn-primary">
</form>
</div>
</div>
<?php require "./template/footer.php"; ?>