COM372X—Programming assignment, week 6
(given 2/26 | due 3/6)

(syllabus | grading)

Assignment 6: Building a Front End

Purpose To build a PHP-MySQL Front End to Use a Database

The assignment: The Book-O-Rama database uses five tables to allow customers to order books and to read book reviews. In chapter 10, we use command line or phpMyAdmin to create the tables and enter some initial values. In chapter 11, we begin to write PHP scripts to connect to the database to retrieve and to manipulate the database. Here, we're going to write a complete user interface, making it possible for a user to look for books, to order them, or to read book reviews; we'll call this the front end to the database. In our next assignment, we'll write the back end, making it possible to add, modify, or delete any record in the 5 tables of the database.

Our goal is to allow a user to search our book list for a title, author, or ISBN number, and to retrieve information about that book, including reviews. We then want to allow them to add that book to an order, printing up the list of books, their individual book cost, and their order total.

Begin by setting up a form to allow the user to look for any book in the current database. Query the database for all titles or authors and use this to construct a select list from which the user will choose a book. Once chosen, display information about that book, including below the book any reviews for that book. Offer the user a chance to "purchase" the book; when a book is purchased, add its ISBN number to an array; then take the user back to select additional books. When the user indicates that they are finished choosing books, you are to print an alphabetized list of books in the array, in a correct bibliographic form (author, title, ISBN, for example), along with price and total price information.

Between trips to the server, you will want to recall which books have already been ordered. I suggest that you do this as simply as possible, and without using cookies or session variables (which we will learn later). The simplest way to maintain state (i.e., to remember what was ordered) would be to use html hidden input fields to keep passing ISBN's back and forth; alternatively, you could use a text file (chapter 2) or you could create a temporary order table in your database.

The user will need to be able to choose to review the order at any point. This should present a list of books (title and author) and prices, without the reviews.

The user should be able to decide to proceed to checkout, at which point they will want to see a price total. Please add 7% sales tax and $3.49 shipping for the first book plus $1.25 shiiping for each additional book.

Although it is up to you, I suggest that you attempt to keep the forms and responses all on the same php page, using the querystring and select case approach of assignment 2, the grocery list.

Grading: This assignment is worth 5 points. Each of the following are required; each is worth 1 point. One point will be deducted if the assignment is not done by the due date.