Question: Need help with Web Development assignment. I have the database imported and the tables are are populated. I have changed all the information that needs
Need help with Web Development assignment. I have the database imported and the tables are are populated. I have changed all the information that needs my name and password. Im new to PHP and SQL.
Part 1. Set up the database:
-
Use phpMyAdmin to create a database on your computer with the name yourLastName_library.
-
Open the library.sql file from Pilot and edit line 3 so that the database name matches the one created
in the previous step. You may not make any other changes to this file.
-
From phpMyAdmin, import the library.sql file from Pilot into the database. This will create and populate the tables.
Part 2. Complete the website:
-
Download and extract the assign3.zip folder on Pilot. Put this folder in your htdocs folder, and complete it as directed below.
-
Edit the open_db.php file (located in the inc folder). Edit lines 3 through 5 so that it is using your username, password, and database. Be sure you use the same username and password here as you do for the database. This should also be the same as the course server, so that you wont need to edit anything when you upload it there.
-
Complete the functions. While the header for almost all of the functions used in this website have been written, many of the function bodies need to be implemented. Open each of the files in the functions folder and complete the functions according to the comments above the headers. You may not make any changes to the function headers or to any other provided code in these files.
-
Add a function. Within the checkout_functions.php file, write a function that queries the database and returns a list of all books currently on loan by the library. The result returned by the function needs to include the title, author, patron first name, patron last name, and date checked out for each book.
-
Edit the html. Note: You may make only the changes listed here! Any other changes will result in deductions from your assignment score.
-
Edit the open_db file in the inc folder so that it uses your username and password.
-
Edit the footer.php file in the inc folder so that your name is used instead of the instructor name.
-
Complete the loan.php page. Write the necessary php and html code to call the function you wrote in step 2, and then display all books currently on loan. The books should be displayed as a table with the following columns: Title, Author, Patron Name (first and last), and Date checked out. If a patron has more than one copy of a book, it will be displayed on separate rows since that is how it is stored in the loans table. While we would normally want to avoid duplication, for the purpose of this assignment you may leave it that way. If there are no books currently on loan, display an appropriate message; do NOT display an empty table.
-
Here is the book table

Here is the Loan table thats empty for now

Here is the patrons table.

Here are the functions i have done and still need to do.



HT- isbn title author total _copies avail_copies genre Edit ^i Copy Delete 0061348112 The Indifferent Stars Above Daniel James Brown 4 nonfiction 4 fiction 5 fantasy 4 fantasy 6 fantasy 5 fantasy 4 fantasy 4 fantasy 3 fantasy 3 fantasy 3 fantasy 4 fantasy 4 nonfiction 3 fiction 2 nonfiction 2 biography 3 biography 5 nonfiction 2 nonfiction 2 biography 3 nonfiction 3 fiction 3 fiction 5 fiction Jojo Moyes Edit ^i Copy Delete 0439064872 Harry Potter and the Chamber of Secrets J.K. Rowling Edit Copy G) Delete 0439136369 Harry Potter and the Prisoner of Azkaban JK Rowling J.K. Rowling op Edit Copy G) Delete 0439358078 Harry Potter and the Order of the Phoenix J.K Rowling Edit ^i Copy Delete 0439765960 Harry Potter and the Half-Blood Prince J.K. Rowling Copy Delete 0545139708 Harry Potter and the Deathly Hallows J.K. Rowling Copy G) Delete 0143108867 After You 4 dp Edit Copy Delete 04391 39600 Harry Potter and the Goblet of Fire 4 Edit 3 Copy Delete 054792819x The Return of the King J.R.R. Tolkien J.R.R. Tolkien J.R.R. Tolkien J.R.R. Tolkien Daniel James Brown Jojo Moyes David McCullough David McCullough David McCullough Bryan Stevenson Bryan Stevenson David McCullough Daniel James Brown Khaled Hosseini Khaled Hosseini Khaled Hosseini Copy Delete 0547928203 The Two Towers Edit e CopyDelete 0547928211 The Fellowship of the Ring Edit CopyDelete 054792822X The Hobbit O dp Edit Copy Delete 067002581x The Boys in the Boat Edit Copy G) Delete 0670026603 Me Before You Edit ^i Copy Delete 0671244094 The Path Between the Seas GP Edit Copy G) Delete 0671869205 Truman Edit 3 Copy Delete 0743223133 John Adams op Edit O dp Edit GP Edit O dp Edit op Edit Copy G) Delete 0812994520 Just Mercy Copy Copy G) Delete 1476728742 The Wright Brothers Copy Delete 1468587382 Five Kids and One Gun Delete 1493022008 Under a Flaming Sky Copy G)) Delete 1594489505 A Thousand Splendid Suns Edit ^i Copy Delete 159463193X Kite Runner Edit . Copy G) Delete 1594632383 And the Mountains Echoed SELECT FRONloans isbn card number date checked out card number first name last name email Edit ^i Copy Delete cn11223 op Edit Copy G) Delete cn12345 Edit e CopyDelete cn 13935 ep Edit Copy G) Delete cn23456 O dp Edit Copy Delete cn35738 Edit Copy G) Delete cn44775 Edit 3 Copy Delete cn78324 Op Edit Copy Delete cn7962 1 Edit 3 Copy Delete cn83987 Edit CopyDelete cn95938 o Edit Copy Delete cn98325 Malcolm Julia Mark Howard Gretchen Hil Jerome Jean Beth Charles Karen Patrick Wagner Desai Smith Gordon Wallace Griffin Woodard Little Puckett Hill wagner@email.com desai@email.com smith@email.com gordon@email.com hill3@email.com wallace @email.com griffin@email.com woodard@email.com little@email.com puckett@email.com hill2@email.com 4 function getALLBooks($db) 5 Squery 'SELECT FROM books 6 Sstatement $db->prepare(Squery); 7$statement-execute); 8 Sbooks $statement->fetchALL(PDO:: FETCH_ASSOC) 9 $statement->closeCursor); return $books 3 function getAvai LCopies(Sdb, sisbn) 4 Squery 'SELECT avail_copies FROM books WHERE isbn :isbn 16 Sstatement $db->prepare($query) 8 Sstatement->bindValue(':isbn', sisbn); 9 $statement->execute); Sresult $statement->fetch); Sstatement->closeCursor); 2 return $result ['avail_copies'] 5 //this function returns the title only for the requested isbn 6 function getTitle($db, Sisbn) 29 //this function returns the author only for the requested isbn. function getAuthor($db, $isbn) 4 5 function getBookHTML($db, $book) $image_file "img/books/".Sbook['isbn'].".jpg" 38 89 $htmlout = img srce"Isimage file!" alt-"(Sbook['title'])"> figcaption{$bookl. title"]}
by {$book ['author'])-br /> isbn {$bookl.isbn'j}
Copies available: {Sbookl'avail_copies1}
clabel for Isbook['isbn'1)>Borrow this book 13 16 EOD 2 return $html_out; 6 7 function checkoutBook($db, $isbn, Scard_ number) Squery = 'INSERT INTO loans (isbn, card-number, date-checked-out) sstatement $db->prepare($query) Sstatement->bindValue(':isbn', $isbn); Sstatement->bindVa lue(':card number, Scard_number); sstatement-execute); Sstatement->closeCursor); VALUES (isbn, :card-number, NOW())'; //this function deletes the row from the loans table with the given checkout id function returnBook($db, sisbn, scard_number, Sdate_checked_out) //this function updates the books table by changing the quantity for the book with the given isbn. /ote that the parameter, Sqty_increase, may be a positive or negative number function updateAvailCopies($db, sisbn, sqty_change) 73 1 prepare($query); last_name'; 6 $statement->execute); 7Spatrons-$statement->fetchALL); 8 Sstatement->closeCursor); return $patrons; 9 10 2 //this function returns all information from the patrons table for the patron with the given card number 13 function getPatronInfo($db, $card_number) 14 15 16 17 8 //this function returns isbn, date_checked out, title and author 9 //for all books Loaned to the patron with the given card number 20 function getLoansByPatron(Sdb, $card_ number) 21 23 25 27 ?> HT- isbn title author total _copies avail_copies genre Edit ^i Copy Delete 0061348112 The Indifferent Stars Above Daniel James Brown 4 nonfiction 4 fiction 5 fantasy 4 fantasy 6 fantasy 5 fantasy 4 fantasy 4 fantasy 3 fantasy 3 fantasy 3 fantasy 4 fantasy 4 nonfiction 3 fiction 2 nonfiction 2 biography 3 biography 5 nonfiction 2 nonfiction 2 biography 3 nonfiction 3 fiction 3 fiction 5 fiction Jojo Moyes Edit ^i Copy Delete 0439064872 Harry Potter and the Chamber of Secrets J.K. Rowling Edit Copy G) Delete 0439136369 Harry Potter and the Prisoner of Azkaban JK Rowling J.K. Rowling op Edit Copy G) Delete 0439358078 Harry Potter and the Order of the Phoenix J.K Rowling Edit ^i Copy Delete 0439765960 Harry Potter and the Half-Blood Prince J.K. Rowling Copy Delete 0545139708 Harry Potter and the Deathly Hallows J.K. Rowling Copy G) Delete 0143108867 After You 4 dp Edit Copy Delete 04391 39600 Harry Potter and the Goblet of Fire 4 Edit 3 Copy Delete 054792819x The Return of the King J.R.R. Tolkien J.R.R. Tolkien J.R.R. Tolkien J.R.R. Tolkien Daniel James Brown Jojo Moyes David McCullough David McCullough David McCullough Bryan Stevenson Bryan Stevenson David McCullough Daniel James Brown Khaled Hosseini Khaled Hosseini Khaled Hosseini Copy Delete 0547928203 The Two Towers Edit e CopyDelete 0547928211 The Fellowship of the Ring Edit CopyDelete 054792822X The Hobbit O dp Edit Copy Delete 067002581x The Boys in the Boat Edit Copy G) Delete 0670026603 Me Before You Edit ^i Copy Delete 0671244094 The Path Between the Seas GP Edit Copy G) Delete 0671869205 Truman Edit 3 Copy Delete 0743223133 John Adams op Edit O dp Edit GP Edit O dp Edit op Edit Copy G) Delete 0812994520 Just Mercy Copy Copy G) Delete 1476728742 The Wright Brothers Copy Delete 1468587382 Five Kids and One Gun Delete 1493022008 Under a Flaming Sky Copy G)) Delete 1594489505 A Thousand Splendid Suns Edit ^i Copy Delete 159463193X Kite Runner Edit . Copy G) Delete 1594632383 And the Mountains Echoed SELECT FRONloans isbn card number date checked out card number first name last name email Edit ^i Copy Delete cn11223 op Edit Copy G) Delete cn12345 Edit e CopyDelete cn 13935 ep Edit Copy G) Delete cn23456 O dp Edit Copy Delete cn35738 Edit Copy G) Delete cn44775 Edit 3 Copy Delete cn78324 Op Edit Copy Delete cn7962 1 Edit 3 Copy Delete cn83987 Edit CopyDelete cn95938 o Edit Copy Delete cn98325 Malcolm Julia Mark Howard Gretchen Hil Jerome Jean Beth Charles Karen Patrick Wagner Desai Smith Gordon Wallace Griffin Woodard Little Puckett Hill wagner@email.com desai@email.com smith@email.com gordon@email.com hill3@email.com wallace @email.com griffin@email.com woodard@email.com little@email.com puckett@email.com hill2@email.com 4 function getALLBooks($db) 5 Squery 'SELECT FROM books 6 Sstatement $db->prepare(Squery); 7$statement-execute); 8 Sbooks $statement->fetchALL(PDO:: FETCH_ASSOC) 9 $statement->closeCursor); return $books 3 function getAvai LCopies(Sdb, sisbn) 4 Squery 'SELECT avail_copies FROM books WHERE isbn :isbn 16 Sstatement $db->prepare($query) 8 Sstatement->bindValue(':isbn', sisbn); 9 $statement->execute); Sresult $statement->fetch); Sstatement->closeCursor); 2 return $result ['avail_copies'] 5 //this function returns the title only for the requested isbn 6 function getTitle($db, Sisbn) 29 //this function returns the author only for the requested isbn. function getAuthor($db, $isbn) 4 5 function getBookHTML($db, $book) $image_file "img/books/".Sbook['isbn'].".jpg" 38 89 $htmlout = img srce"Isimage file!" alt-"(Sbook['title'])"> figcaption{$bookl. title"]}
by {$book ['author'])-br /> isbn {$bookl.isbn'j}
Copies available: {Sbookl'avail_copies1}
clabel for Isbook['isbn'1)>Borrow this book 13 16 EOD 2 return $html_out; 6 7 function checkoutBook($db, $isbn, Scard_ number) Squery = 'INSERT INTO loans (isbn, card-number, date-checked-out) sstatement $db->prepare($query) Sstatement->bindValue(':isbn', $isbn); Sstatement->bindVa lue(':card number, Scard_number); sstatement-execute); Sstatement->closeCursor); VALUES (isbn, :card-number, NOW())'; //this function deletes the row from the loans table with the given checkout id function returnBook($db, sisbn, scard_number, Sdate_checked_out) //this function updates the books table by changing the quantity for the book with the given isbn. /ote that the parameter, Sqty_increase, may be a positive or negative number function updateAvailCopies($db, sisbn, sqty_change) 73 1 prepare($query); last_name'; 6 $statement->execute); 7Spatrons-$statement->fetchALL); 8 Sstatement->closeCursor); return $patrons; 9 10 2 //this function returns all information from the patrons table for the patron with the given card number 13 function getPatronInfo($db, $card_number) 14 15 16 17 8 //this function returns isbn, date_checked out, title and author 9 //for all books Loaned to the patron with the given card number 20 function getLoansByPatron(Sdb, $card_ number) 21 23 25 27 ?>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
