} else { echo "You currently have " . $count . " books in your library."; } ?> </h2> </div> <div id="lastbook"> <?php if ($count != 0) { echo '<h2 style="margin-top:70px;">Last book you added;</h2>'; $result = $del->fetchAll(); //print_r($result[$count-1]); $row = $result[$count - 1]; //echo $row['book_name']; $lastbook = new book($user_id, $row['book_name'], $row['author'], $row['genre'], $row['publisher'], $row['location'], $row['book_id']); $lastbook->display_books_search(); //echo "lol"; } ?> </div> </section>
//Headers already sent errro. TO DO //header('book.php?id=' . $query); } else { $validID = false; echo "<h2>Please only enter numeric input for Book ID</h2>"; } } else { $raw_results = $DB_con->prepare("SELECT * FROM books\n WHERE (`user_id` LIKE {$user_id} ) AND \n ((`book_name` LIKE '%" . $query . "%') OR \n (`book_id` LIKE '%" . $query . "%') OR \n (`location` LIKE '%" . $query . "%')OR \n (`genre` LIKE '%" . $query . "%') OR \n (`publisher` LIKE '%" . $query . "%') OR \n (`author` LIKE '%" . $query . "%'))"); } } if ($validID) { $raw_results->execute(); if ($raw_results->rowCount() > 0) { while ($results = $raw_results->fetch(PDO::FETCH_ASSOC)) { $newbook = new book($user_id, $results['book_name'], $results['author'], $results['genre'], $results['publisher'], $results['location'], $results['book_id']); $newbook->display_books_search(); } } else { // if there is no matching rows do following echo "<h2>No results</h2>"; } } } else { // if query length is less than minimum //echo "Minimum length is ".$min_length; echo "<h2>Enter something.</h2>"; } if (isset($check)) { $user->display_add_message($check, $newbook); } ?>