Детален приказ на книга
Актери
- Најавен корисник
Чекор 1
Корисникот ја избира книгата за која сака да види подетални информации
Чекор 2
$sql = "SELECT book.*, book_details.*, firstname, lastname, author_description, author_image FROM book INNER JOIN book_author ON book.bookid = book_author.bookid INNER JOIN author ON book_author.authorid = author.authorid INNER JOIN book_details ON book.bookid = book_details.bookid WHERE book.bookid = :bookid; "; $stmt = $conn->prepare($sql); $stmt->bindParam(':bookid', $param, PDO::PARAM_INT); $sql2 = "SELECT b.BookID, b.TotalCopies - COALESCE(COUNT(l.LoanID), 0) AS AvailableCopies FROM Book b LEFT JOIN Loan l ON l.BookCopyID IN (SELECT CopyID FROM Book_Copies WHERE BookID = b.BookID) AND l.Status IN ('On Time', 'Soon', 'Overdue') WHERE b.BookID = :bookid GROUP BY b.BookID, b.TotalCopies;";
Чекор 3
//Similar Books $stmt = $conn->prepare("SELECT book.bookid, coverimage, title, genre, firstname, lastname FROM book INNER JOIN book_author ON book.bookid = book_author.bookid INNER JOIN author ON book_author.authorid = author.authorid WHERE book.genre = :bookgenre AND book.bookid != :bookid LIMIT 5; "); $stmt->bindParam(':bookgenre', $book_genre, PDO::PARAM_STR); $stmt->bindParam(':bookid', $bookid, PDO::PARAM_INT); // Execute the query $stmt->execute(); $similar_books = []; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $similar_books[] = $row; } //More Author $stmt = $conn->prepare("SELECT book.bookid, coverimage, title, genre, firstname, lastname FROM book INNER JOIN book_author ON book.bookid = book_author.bookid INNER JOIN author ON book_author.authorid = author.authorid WHERE book_author.authorid IN ( SELECT book_author.authorid FROM book_author WHERE book_author.bookid = :bookid ) AND book.bookid != :bookid LIMIT 5; "); $stmt->bindParam(':bookid', $bookid, PDO::PARAM_INT); // Execute the query $stmt->execute(); $author_books = []; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $author_books[] = $row; }
Last modified
4 days ago
Last modified on 01/11/25 15:10:43
Attachments (3)
- BT-DB-2.png (236.2 KB ) - added by 4 days ago.
- BT-DB-1.png (88.1 KB ) - added by 4 days ago.
- BT-DB-3.png (118.4 KB ) - added by 4 days ago.
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.