Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2011Spring

01.10.11 - 05.06.11

PHP Programming (Blended)

CSYS2463

Monday Wednesday
02:00 PM - 03:20 PM

Lightsabers

Lab06

Objective: Practice using PHP with MySQL

pastdue

Submit Your Solution

Lab06

Request a Copy of your Solution

Lab06

Requirements

Comments placed the source code file5 pts
Table data can be viewed and includes picture15 pts
New records can be added to the table25 pts
Records can be edited25 pts
Records can be deleted20 pts
Forms are easy to use, perform validation, and include defaults10 pts
Total100 pts

Instructions

Biag Raw has approached you with a new problem. He is currently planning on starting a website where he will sell lightsabers. All of the information about the lightsabers that are to be eventually displayed for sale on their website are to be stored in a MySQL database but Biag is concerned that the database will be too difficult to manage if SQL has to be written manually to work with their database.

Mr. Raw would like for you to create a page or set of pages written in PHP that could be used in place of writing SQL to update the database. The solution will need to include a way for the sites operators to see (Read) all of the information currently in the database, to be able to add new lightsabers (Create), to edit listing for lightsabers already in the database (Update), and to delete lightsabers that are no longer being sold (Delete). Images of the lightsabers will be included and should be displayed as images when the table data is viewed. The images should be specified when adding or editing lightsaber listings by filename.

The solution will eventually be used by hired help so everything needs to be easy to use and as intuitive as possible. Any forms used should be validated to the greatest possible extent to ensure that bad data does not get into the database.

Your database designer has consulted with Mr. Raw and has decided that the following tables should be sufficient for the customers needs. You'll need to create the alignments table first followed by the lightsabers table.

Alignments table:

create table alignments (
    id int not null auto_increment,
    description varchar(100) not null,
    primary key(id)
)

insert into alignments (description) values ('Light Side')
insert into alignments (description) values ('Dark Side')

Lightsabers table:

create table lightsabers (
    id int not null auto_increment,
    name varchar(50) not null,
    description text not null,
    price float not null,
    image varchar(100) not null default 'images/na.gif',
    alignment int not null,
    primary key(id),
    foreign key(alignment) references alignments(id)
)

The Alignments table will change very infrequently if at all so no interface is required for it. Simply insert the two values above so that there will be values which will be needed by the lightsabers table. Remember that the alignment field in the lightsabers table references the id values in the alignments table so one of these id's must be present in any new lightsaber record.

Extras