CSE3MS Lab 4 - More MySQL tables and PHP scripts
Laboratory four addresses a simple design problem using
MySQL and PHP. In this laboratory you will use create new
customised database tables and create
custom SQL queries on that table.
The data is to be stored and processed using PHP
to issue MySQL commands.
See a demo
of desired application.
Exercise 1
Use the information on creating database tables given
in Lab 3 to create a new database in which to store
product information. For each product you need to
store a product code, description, cost price, and
markup percentage. Make suitable assumptions about the
field types.
Exercise 2
Write a master page that provides links to forms
and PHP scripts that provide the following functions.
- Add a product to the table
- Display a pricelist
Exercise 3
Write a HTML form and associated PHP script that allows
an administrator to add items to the database of
product items. Your script should check for product
code duplication before adding an entry.
If the code is a duplicate then you should report
an error and the conflicting data that already exists.
Adding a product should be done via a form that communicates to
a PHP script on the server to generate appropriate SQL commands
for the MySQL server adding the requested data.
Refer to Lab 2 on how to pass information from a form into
variables in a server side PHP script.
Exercise 4
Write a PHP script that prints a price list for browsing.
The price list should be a table that displays
product code, description and sale price. The sale
price is computed from the cost price using the
percentage markup stored in the table.