Challenge 4-1 - Enhance the Product Manager Application

Challenge 4-1 - Enhance the Product Manager application

In this challenge you will enhance the Product Manager application by adding a feature that lets you delete categories. At the end of the exercise, you will upload your work to the class server.

  1. Start with the challenge_4_1.zip file provided by your instructor. Set up a NetBeans project.
  2. If you haven’t already done so, you will need to run the create_db.sql script in order to create the my_guitar_shop1 database on your local computer.
  3. Take note of the code already provided to you. It already successfully reads from the my_guitar_shop1 database. It also has a working feature that allows you to list, add and delete products.
  4. Give it a try. See if you can, using the provided code, add a new product, see it appear in the list, and then delete it. (Take note, your haven’t written a line of code yet…. your still just exploring and making sure everything is set up OK.)
  5. Now, click on the “List Categories” link at the bottom of the page. Note that this link leads to a page that is under construction. However the link back to the Product List page doesn’t work.
  6. In the rest of this exercise, you’ll add a page that looks like this:
  7. Don’t worry about the “Add Category” feature just yet. You will work on that in the next exercise.
  8. Because we will work on deleting categories in this challenge, you will want to add some extra categories into the categories table of the database, just so you can delete them later. If you need to restore your database to its original state, you can always rerun create_db.sql.
  9. Open the category_list.php file that’s in the application directory. It contains some of the headings and a link back to the Product List page.
  10. In the category_list.php file, write the PHP code that creates the HTML table shown in the above diagram. You should be writing a loop that will step through the records in the categories table found in the database. Some notes:
  11. A very similar piece of code exists in index.php that displays the products. You should start by looking at that.
  12. The category name should appear in the name column, and the Delete button should appear in the second column.
  13. Notice that each Delete button is its own form. Look closely at the index.php and determine how this is being done there. Then follow that example. The form uses an input tag of type “hidden” to pass the primary key of the product to delete.
  14. Notice that index.php relies on a file named delete_products.php to actually carry out the delete operation. That means that you need to make a copy of delete_poducts.php and name in delete_categories.php. Edit delete_categories.php accordingly.
  15. Test your work. You should be able to see a list of categories on category_list, and then delete a category by clicking on it.
  16. Upload your work to mis3501.temple.edu, and get it working there. This includes:
  17. editing database.php so that your database credentials are specified there
  18. exporting your local database, and importing it into your assigned database on mis3501.temple.edu
  19. uploading your files using ssh.