Question: i got php codes here for book.php , DatabaseConnection.php , Functions.php and they are working correctly with main.php code below. i am trying to built
i got php codes here for book.php DatabaseConnection.php Functions.php and they are working correctly with main.php code below.
i am trying to built a library management system that will addBook, displayBooks and searchBook
Modify below code to allow me to add, view and search fo books on the web application instead of inside the CLI application in php
The escatic of the web application should be moden, therefore add colur to it
book.php
title $title;
$thisauthor $author;
$thisisbn $isbn;
$thisgenre $genre;
Getter methods for book properties
public function getTitle
return $thistitle;
public function getAuthor
return $thisauthor;
public function getISBN
return $thisisbn;
public function getGenre
return $thisgenre;
Method to display book information
public function displayBookInfo
echo "Title: $thistitle
;
echo "Author: $thisauthor
;
echo "ISBN: $thisisbn
;
echo "Genre: $thisgenre
;
function.php
prepare$sql;
$stmtexecute
:title' $bookgetTitle
:author' $bookgetAuthor
:isbn' $bookgetISBN
:genre' $bookgetGenre
;
echo "Book added successfully.
;
catch PDOException $e
Handle errors during the insert operation
echo "Error adding book: $egetMessage;
Function to display all books from the database
function displayBooks
$pdo getPDOConnection;
SQL query to select all books
$sql "SELECT FROM books";
try
$stmt $pdoquery$sql;
$books $stmtfetchAll;
if $books
foreach $books as $book
Display each book's details
echo "Title: $booktitle
;
echo "Author: $bookauthor
;
echo "ISBN: $bookisbn
;
echo "Genre: $bookgenre
;
echo
;
else
echo No books found.
;
catch PDOException $e
Handle errors during the select operation
echo "Error displaying books: $egetMessage;
Function to search for books by title
function searchBook$title
$pdo getPDOConnection;
SQL query to search for books by title using a LIKE clause
$sql "SELECT FROM books WHE
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
