<h1>Book Listings</h1> <table> <tr> <th> Title </th> <th> Author </th> <th> ISBM Number </th> <th> Price ($) </th> <th> Others in Series </th> </tr> <?php printBooks($books); ?> </table> <style> table {width: 100%;} td {border: 1px solid black} th {border: 2px solid black} </style> </body> </html>
} echo "Author: " . $_GET['bookAuthor']; } else { $bookAuthor = ""; } if (isset($_GET['category'])) { $category = $_GET['category']; } else { $category = ""; } // SQL to get all the books that contain the searched title and/or author $sql = "SELECT b.ISBN, b.BookTitle, b.Author, b.Edition, b.Year, c.CategoryDescription, b.Reserved \n\t\t\t\t\t\t\tFROM Books b JOIN Categories c ON(b.Category = c.CategoryID)\n\t\t\t\t\t\t\tWHERE b.bookTitle LIKE '%{$bookTitle}%' AND b.Author LIKE '%{$bookAuthor}%' AND c.categoryID LIKE '%{$category}%'"; // Read the data into the variable books readData($sql, $books); // Print the books array printBooks($pageNo, $books, "Reserve"); // Create a form with two buttons that has the value of the next or previous page echo '<form type = "GET">'; echo '<input type = "hidden" name = "bookTitle" value = "' . $bookTitle . '">'; echo '<input type = "hidden" name = "bookAuthor" value = "' . $bookAuthor . '">'; echo '<input type = "hidden" name = "category" value = "' . $category . '">'; if ($pageNo != 0) { echo '<button name = "page" value = ' . ($pageNo - 1) . ' class = "leftArrow"> < </button>'; } if (($pageNo + 1) * 5 < count($books)) { echo '<button name = "page" value = ' . ($pageNo + 1) . ' class = "rightArrow"> > </button>'; } echo '</form>'; // Close the database mysql_close($db); }
// Read the data into the variable books readData($sql, $books); // Display message if there are no reservations made by the current user if (!isset($books)) { echo '<h3 style = "text-align: center">You don\'t have any reservations.</h3>'; } else { // Check if there are any books to display on the page if (count($books) < $pageNo * 5 + 1) { $pageNo--; if ($pageNo == -1) { $pageNo = 0; } header("Location: Reservations.php?page=" . $pageNo); } // Print the books array printBooks($pageNo, $books, "Return"); // Create a form with two buttons that has the value of the next or previous page echo '<form type = "GET">'; if ($pageNo != 0) { echo '<button name = "page" value = ' . ($pageNo - 1) . ' class = "leftArrow"> < </button>'; } if (($pageNo + 1) * 5 < count($books)) { echo '<button name = "page" value = ' . ($pageNo + 1) . ' class = "rightArrow"> > </button>'; } echo '</form>'; } // Close the database mysql_close($db); } ?> </div>