Menu

(Solved) : Part 1 Databases Forms Read Database Access Php Copy Form Lab Exercise6 L7p1php Change Rea Q28893718 . . .

Part 1; From databases to forms: Read DatabaseAccess with PHP. Copy your form from Lab Exercise6 to l7p1.php andchange it to read the states from a database table instead ofputting them into a PHP array yourself.

The database is named weblab and the table of states is namedstate_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 stateabbreviation through the form. You do this by using avalue attribute on the

element. The form area for State will look something like thefollowing. Of course, you have to build this using PHP, and notjust type it in.

AlabamaFloridaGeorgiaTennessee

You will not use the state_zone attribute. In “real life” itwould be used for calculating shipping, maybe.

Present the state names in alphabetical order on your form. Theeasy way to do this is to have the database management system sortthem for you using an ORDER BY clause in your SQL. For those of youwho took Database long ago and far away (or not at all!), asuitable 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 databaseweblab has a table of tools named tool_t. The table was created asfollows:

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 andweights by extracting the items from the database rather thanhard-coding them. Display every item from the database. Do notassume 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 theright of the decimal point.

Your order form should display the following items for eachtool:

Name

Price

Shipping Weight

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

You will not need the tool_picture ortool_description attributes. Present the tool names inalphabetical order. The following is a suitable query forretrieving from the database:

select tool_item_no, tool_name, tool_price, tool_weight from tool_torder by tool_name;

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

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

Part 3; Thinking about database items: Answerthe following question: The query you were given in Part 2retrieved the tool_item_no attribute from the database.Did you do anything with it? Why, or why not? Hint: Is itremotely 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 itfrom your index page.

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

here is my form:

<form name=”form1″action=”http://weblab.kennesaw.edu/formtest.php” onsubmit=”returnquantityValidation();” method=”get”>

<table>

<tr>

<td>Customer Name</td>

<td><input type=”text” name=” name”></td>

</tr>

<tr>

<td>crate Quantity</td>

<td><input type=”text” id=”crate_qty” name=”crateunit”></td>

</tr>

<tr>

<td>hoes Quantity</td>

<td><input type=”text” id=”skate_qty” name=”skateunit”></td>

</tr>

<tr>

<td>saw Quantity</td>

<td><input type=”text” id=”saw_qty” name=”sawunit”></td>

</tr>

<tr>

<td>ShippingAddress</td>

<td><input type=”text” name=”Shipping”></td>

</tr>

<tr>

<td>State</td>

<td>

<select name=”Payment mode” style=”width:140px” ;”>

<option value=”maine”> GA </option>

<option value=”Florida”> FL</option>

<option value=”california”>TX</option>

</select>

</td>

</tr>

<tr>

<td>Payment type</td>

<td>

<select name=”Payment mode” style=”width:140px” ;”>

<option value=”mastercard”> mastercard </option>

<option value=”visa”> master</option>

<option value=”Amex”>Express</option>

</select>

</td>

</tr>

<tr>

<td><input type=”submit” onclick=”validateForm()”value=”Place order”></td>

<td><input type=”reset” value=”ClearForm”></td>

</tr>

</table>

<label style=”color:blue;”id=”labelError”></label>

</form>

Expert Answer


Answer to Part 1 Databases Forms Read Database Access Php Copy Form Lab Exercise6 L7p1php Change Rea Q28893718 . . .

OR