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

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 a value 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;

From lab 6 code:

My Table

My Table

Tool Name Price Shipping weight
Chisels $3.00 6.6 b
Hoe $8.00 8.8b
Monkey_wrench $9.50 10.2b
Customer Name
Chisels Quantity
Hoe Quantity
Monkey_wrench Quantity
Shipping Address

Payment Mode: Visa Master Card American Express

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_description attributes. 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.

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.

Part 5; Reflecting on what you've learned: Tell at least one thing, more if possible, that you expected to get out of this course, but did not. (Please note: I'm asking for help to improve the course. A list of things that were missing is much more useful to me than a statement that the course was perfect in every way.) Put your notes on 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

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions