Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1; From databases to forms: Read Database Access with PHP. Copy your form from Lab Exercise6 to l7p1.php and change it to read the

<----- ONLY NEED PART 3 & 4 ----->

Part 1; From databases to forms: Read Database Access with PHP. Copy your form from Lab Exercise6 to l7p1.php and change it to read the states from a database table instead of putting them into a PHP array yourself.

The database is named weblab and the table of states is named state_t. The table was created as follows:

CREATE TABLE state_t ( state_abbr char(2) PRIMARY KEY, state_name char(20), state_zone integer); 

Display the state name in the drop-down, but transmit the state abbreviation through the form. You do this by using avalue attribute on the

 

You will not use the state_zone attribute. In "real life" it would be used for calculating shipping, maybe.

Present the state names in alphabetical order on your form. The easy way to do this is to have the database management system sort them for you using an ORDER BY clause in your SQL. For those of you who took Database long ago and far away (or not at all!), a suitable query for populating the array is this:

SELECT state_abbr, state_name from state_t ORDER BY state_name; 

Make a link to this program from your index page.

Part 2, More databases to forms: The database weblab has a table of tools named tool_t. The table was created as follows:

CREATE TABLE tool_t ( tool_item_no char(10) PRIMARY KEY, tool_name char(20), tool_price numeric(6, 2), tool_weight numeric(4, 1), tool_picture char(30), tool_description varchar); 

Change your order form to construct the item names, prices and weights by extracting the items from the database rather than hard-coding them. Display every item from the database. Do not assume that there will be a given number of items.

In the database table definition above, numeric(6, 2) means the item has a total of six digits, of which two are to the right of the decimal point.

Your order form should display the following items for each tool:

Name

Price

Shipping Weight

Each idem of your form should have a box to allow the customer to enter quantity as you did in earlier assignments.

You will not need the tool_picture or tool_descriptionattributes. Present the tool names in alphabetical order. The following is a suitable query for retrieving from the database:

select tool_item_no, tool_name, tool_price, tool_weight from tool_t order by tool_name; 

This is a modification of l7p1.php, and I will test it when I test Part 1. Your program will still be named l7p1.php.

Note: This change will "break" your JavaScript validation routines if you still have them in your form. In real life, you would have to fix this. However, in real life, you would have started with the database-driven form, so you would not have to back-track. You do not have to change your validation routines, but see Part 4 below.

<------ This is lab excercise 6 ------>

values





Part 3; Thinking about database items: Answer the following question: The query you were given in Part 2 retrieved the tool_item_no attribute from the database. Did you do anything with it? Why, or why not? Hint: Is it remotely possible that two different tools may have the same name? Another hint: See Part 4.

Put your answer on a Web page, l7p3.html and make a link to it from your index page.

Part 4; Thinking about form data validation: Explain in no more than a paragraph each what you would have to do with your JavaScript validation to make it work with the database-driven order form. You may put your answer on the same page as Part 3. Please be sure I can tell which answer is which.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. Use graphics software and existing graphics effectively.

Answered: 1 week ago