Answered step by step
Verified Expert Solution
Question
1 Approved Answer
murach's php and mysql 4 th edition Exercise 1 9 - 1 / pg 6 6 7 Exercise 1 9 - 1 Use PHP to
murach's php and mysql th edition Exercise pg
Exercise Use PHP to work with a database.
Review and test the code
Run the application in the exstartschex directory. This should display the names of the products in the Basses category, a delete message, and an insert message.
Open the database.php file the productdbphp file, the categorydbphp file, and the index.php file. Then, review the cod. Note that this code uses PDO.
If you want to use mysqli instead of PDO, replace the database.php productdbphp and categorydbphp files with the database.php productdbphp and categorydbphp files that are in the bookapps chguitarshopmysqlimodel directory.
Modify the code
Modify the index.php file so it displays the products that are in the Guitars category.
Modify the index.php file so it uses a method from the model to add a product. When you do that, use the sample data thats already in the index.phpfile. Make sure this code displays an appropriate message that indicates whether the product was inserted. Note that the products table requires a unique product code for each product. As a result, you cant insert the same product code twice.
Add a method to the model named getProductByName This method should have a parameter for the product name and it should return a product object for the product with the specified name. This provides a way to get the product ID and other product data that corresponds to the product name.
Modify the index.php file so it uses a method from the model to delete the product named Fender Telecaster To do that, you can use the method that you created in the previous step to get the product ID Make sure this code displays an appropriate message that indicates whether the product was deleted.
Test the code to make sure it works correctly. If it does, it should display the products, add a product, and display appropriate messages.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started