-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.php
71 lines (68 loc) · 2.19 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
<?php
session_start();
$book_isbn = $_GET['bookisbn'];
// connecto database
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){
echo "Can't retrieve data " . mysqli_error($conn);
exit;
}
$row = mysqli_fetch_assoc($result);
if(!$row){
echo "Empty book";
exit;
}
$title = $row['book_title'];
require "./template/header.php";
?>
<!-- Example row of columns -->
<p class="lead" style="margin: 25px 0"><a href="books.php">Books</a> > <?php echo $row['book_title']; ?></p>
<div class="row">
<div class="col-md-3 text-center">
<img class="img-responsive img-thumbnail" src="./bootstrap/img/<?php echo $row['book_image']; ?>">
</div>
<div class="col-md-6">
<h4>Book Description</h4>
<p><?php echo $row['book_descr']; ?></p>
<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";
?>