-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbookPerCat.php
47 lines (44 loc) · 1.23 KB
/
bookPerCat.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
<?php
session_start();
require_once "./functions/database_functions.php";
// get pubid
if(isset($_GET['catid'])){
$catid = $_GET['catid'];
} else {
echo "Wrong query! Check again!";
exit;
}
// connect database
$conn = db_connect();
$catName = getCatName($conn, $catid);
$query = "SELECT book_isbn, book_title, book_image FROM books WHERE categoryid = '$catid'";
$result = mysqli_query($conn, $query);
if(!$result){
echo "Can't retrieve data " . mysqli_error($conn);
exit;
}
if(mysqli_num_rows($result) == 0){
echo "Empty books ! Please wait until new books coming!";
exit;
}
$title = "Books Per Category";
require "./template/header.php";
?>
<p class="lead"><a href="category_list.php">Categories</a> > <?php echo $catName; ?></p>
<?php while($row = mysqli_fetch_assoc($result)){
?>
<div class="row">
<div class="col-md-3">
<img class="img-responsive img-thumbnail" src="./bootstrap/img/<?php echo $row['book_image'];?>">
</div>
<div class="col-md-7">
<h4><?php echo $row['book_title'];?></h4>
<a href="book.php?bookisbn=<?php echo $row['book_isbn'];?>" class="btn btn-primary">Get Details</a>
</div>
</div>
<br>
<?php
}
if(isset($conn)) { mysqli_close($conn);}
require "./template/footer.php";
?>