Docsity

ISM 4480 Electronic Commerce Assignment 4: Database Interaction with PHP, Assignments of Information Technology

Toggle sidebar
bg1
ISM 4480 Electronic Commerce
Assignment 4: Working with Databases
In this assignment, you will extend the pizza order entry web site you designed in Assignments 2 and 3.
You will connect the order entry form in pizza1.htm (created in Assignment 3) to new PHP page
pizza4.php, which will insert all order details in the “pizza” database (a MySQL database) hosted on the
infosys server, and display a confirmation message.
You do not need to create your own database for this assignment. You can use the pizza database on the
infosys server, which is available to the entire class. The schema for this database is provided on the next
page.
To complete this assignment, you will need to use the SQL insert statement, with appropriate database
connectivity. All code required for connecting to and inserting new records into the pizza database is
provided in the PHP handout. However, because my sample program was created only for one pizza only
and your assignment is for 50 pizzas, you will have to modify the SQL string to enter all of your order
details. The only challenging part of this assignment is creating the right SQL string. If the SQL string is
incorrect, you will see an error message while trying to run it. To be sure that your program is working
correctly, run the PHP page display_orders.php from the PHP examples handout. If the pizza order you
just added was inserted properly, you should see this record toward the bottom of the displayed records.
A couple of issues about the pizza database that are worth noting:
1. You cannot (and should not) enter any data in the OrderNum and OrderDate fields. OrderNum is
an Auto_Increment field meaning that MySQL automatically enters a unique value into that field
(which is OrderNum for the previous order plus one) whenever a new record is being inserted.
OrderDate is a Timestamp field, meaning that MySQL automatically inserts the system date/time into
that field. You are not allowed to change either of these two values.
2. OrderAmount is the total price for your entire pizza order (for up to 50 pizzas). If the code for
calculating the total order amount (from the previous assignment) is working, you can insert that data
in the OrderAmount field in the database, else you can skip entering this field. You don’t need your
Assignment 3 to work for you to complete this assignment.
3. Don’t enter anything into the Delivered field. It is a binary field that automatically defaults to 0,
meaning that the pizza order is undelivered (as it is entered). In the next assignment, we will see how
to update this value to 1, and use it to track delivered and undelivered orders.
The deliverables to be submitted are:
1. Printout of the code in pizza4.php page.
2. Output of the display_orders.php page showing a pizza order that you entered with your own first
and last name (not all orders in the table, but only the last page showing your own order).
3. Upload all files to your assigned ecxx directory. Include your name and ecxx account as
comment statements at the top of the page.
If you need help with specific PHP or SQL commands, search Google before approaching me for
assistance. The following two websites are also very helpful:
SQL: http://www.w3schools.com/sql/
PHP: http://www.w3schools.com/PHP/default.asp
pf2

Partial preview of the text

Download ISM 4480 Electronic Commerce Assignment 4: Database Interaction with PHP and more Assignments Information Technology in PDF only on Docsity!

ISM 4480 Electronic Commerce

Assignment 4: Working with Databases

In this assignment, you will extend the pizza order entry web site you designed in Assignments 2 and 3.

You will connect the order entry form in pizza1.htm (created in Assignment 3) to new PHP page

pizza4.php, which will insert all order details in the “pizza” database (a MySQL database) hosted on the

infosys server, and display a confirmation message.

You do not need to create your own database for this assignment. You can use the pizza database on the

infosys server, which is available to the entire class. The schema for this database is provided on the next

page.

To complete this assignment, you will need to use the SQL insert statement, with appropriate database

connectivity. All code required for connecting to and inserting new records into the pizza database is

provided in the PHP handout. However, because my sample program was created only for one pizza only

and your assignment is for 50 pizzas, you will have to modify the SQL string to enter all of your order

details. The only challenging part of this assignment is creating the right SQL string. If the SQL string is

incorrect, you will see an error message while trying to run it. To be sure that your program is working

correctly, run the PHP page display_orders.php from the PHP examples handout. If the pizza order you

just added was inserted properly, you should see this record toward the bottom of the displayed records.

A couple of issues about the pizza database that are worth noting:

1. You cannot (and should not) enter any data in the OrderNum and OrderDate fields. OrderNum is

an Auto_Increment field meaning that MySQL automatically enters a unique value into that field

(which is OrderNum for the previous order plus one) whenever a new record is being inserted.

OrderDate is a Timestamp field, meaning that MySQL automatically inserts the system date/time into

that field. You are not allowed to change either of these two values.

2. OrderAmount is the total price for your entire pizza order (for up to 50 pizzas). If the code for

calculating the total order amount (from the previous assignment) is working, you can insert that data

in the OrderAmount field in the database, else you can skip entering this field. You don’t need your

Assignment 3 to work for you to complete this assignment.

3. Don’t enter anything into the Delivered field. It is a binary field that automatically defaults to 0,

meaning that the pizza order is undelivered (as it is entered). In the next assignment, we will see how

to update this value to 1, and use it to track delivered and undelivered orders.

The deliverables to be submitted are:

1. Printout of the code in pizza4.php page.

2. Output of the display_orders.php page showing a pizza order that you entered with your own first

and last name (not all orders in the table, but only the last page showing your own order).

3. Upload all files to your assigned ecxx directory. Include your name and ecxx account as

comment statements at the top of the page.

If you need help with specific PHP or SQL commands, search Google before approaching me for

assistance. The following two websites are also very helpful:

SQL: http://www.w3schools.com/sql/

PHP: http://www.w3schools.com/PHP/default.asp

MySQL database schema (pizza):

Database name: pizza (username: ec, password: ec) Table: orders (37 fields total) Fields: OrderNum Number(11) Not Null Auto_Increment Primary key, OrderDate Timestamp Not Null Default: Current_Timestamp, FirstName Varchar(20), LastName Varchar(20) Not Null, Address Varchar(30) Not Null, City Varchar(20), State Varchar(2), Default: FL, Zip Varchar(10), Phone Varchar(15), Email Varchar(30), Pizza1Size Varchar(10) Not Null, Pizza1Qty Tinyint(3) Not Null Default: 1, Pizza1Top1 Varchar(15), Pizza1Top2 Varchar(15), Pizza1Top3 Varchar(15), Pizza2Size Varchar(10), Pizza2Qty Tinyint(3) Default: 0, Pizza2Top1 Varchar(15), Pizza2Top2 Varchar(15), Pizza2Top3 Varchar(15), Pizza3Size Varchar(10), Pizza3Qty Tinyint(3) Default: 0, Pizza3Top1 Varchar(15), Pizza3Top2 Varchar(15), Pizza3Top3 Varchar(15), Pizza4Size Varchar(10), Pizza4Qty Tinyint(3) Default: 0, Pizza4Top1 Varchar(15), Pizza4Top2 Varchar(15), Pizza4Top3 Varchar(15), Pizza5Size Varchar(10), Pizza5Qty Tinyint(3) Default: 0, Pizza5Top1 Varchar(15), Pizza5Top2 Varchar(15), Pizza5Top3 Varchar(15), OrderAmount Double, Delivered Binary Not Null, Default: 0