-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbooks.php
56 lines (43 loc) · 1.5 KB
/
books.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
<?php
session_start();
require_once "./functions/database_functions.php";
$conn = db_connect();
// $query = "SELECT book_isbn, book_image FROM books";
$query = "SELECT book_isbn, book_image FROM books ORDER BY rand()";
$result = mysqli_query($conn, $query);
$totalBooksFound = mysqli_num_rows($result);
if (!$result) {
$_SESSION["errorArray"]["retrieveFailed"] = "Cannot Retrieve Book Data";
header("Location : nothingFound.php");
exit;
}
$title = "Full Catalogs of Books";
require_once "./template/header.php";
$count = 0;
?>
<p class="lead text-center text-muted">Full Catalog of Books (<?php echo $totalBooksFound; ?>)</p>
<?php for ($i = 0; $i < mysqli_num_rows($result); $i++) { ?>
<div class="row four-books-margin-bottom">
<?php while ($query_row = mysqli_fetch_assoc($result)) { ?>
<!-- text-center is added here to make the book thumbnails in the center -->
<div class="col-md-3 text-center">
<a href="book.php?bookisbn=<?php echo $query_row['book_isbn']; ?>">
<img class="img-responsive img-thumbnail book-hover"
src="./assets/img/<?php echo $query_row['book_image']; ?>" alt="the responsive book image">
</a>
</div>
<?php
$count++;
if ($count >= 4) {
$count = 0;
break;
}
} ?>
</div>
<?php
}
if (isset($conn)) {
mysqli_close($conn);
}
require_once "./template/footer.php";
?>