Menu

[Solved]Copy Form Lab Exercise6 L7p1php Change Read States Database Table Instead Putting Php Arra Q37245276

Copy your form from Lab Exercise6 to l7p1.php and change it toread the states from a database table instead of putting them intoa PHP array yourself. The database is named weblab and the table ofstates is named state_t. The table was created as follows: CREATETABLE state_t ( state_abbr char(2) PRIMARY KEY, state_namechar(20), state_zone integer); Display the state name in thedrop-down, but transmit the state abbreviation through the form.You do this by using a value attribute on the element. The formarea for State will look something like the following. Of course,you have to build this using PHP, and not just type it in.AlabamaFloridaGeorgiaTennessee You will not use the state_zoneattribute. In “real life” it would be used for calculatingshipping, maybe. Present the state names in alphabetical order onyour form. The easy way to do this is to have the databasemanagement system sort them for you using an ORDER BY clause inyour SQL. For those of you who took Database long ago and far away(or not at all!), a suitable query for populating the array isthis: SELECT state_abbr, state_name from state_t ORDER BYstate_name; Make a link to this program from your index page.

Lab 6

<!DOCTYPE html>

<html>

<head>

<title>Lab Exercise 4 Part 3</title>

<style>

.fieldset-auto-width {

display: inline-block;

}

</style>

<script>

function validateForm(){

var a = document.forms[“myForm”][“numOfPlan”].value;
var b = document.forms[“myForm”][“numOfChisels”].value;
var c = document.forms[“myForm”][“numOfPitchforks”].value;
if(a==””) a=0;
else if(b==””) b=0;
else if(c==””) c=0;
if((!/^[0-9]+$/.test(a) )|| (!/^[0-9]+$/.test(b)) ||(!/^[0-9]+$/.test(c))){
alert(“Please enter numbers only !”);
return false;
}
  
else return true;
}

</script>

</head>

<body>

<h1 style=”text-align:center”> Lab Exercise 2 Part 3</h1>

<div style = “text-align: center”> </div>

<style>

h1 { font-family:sans-serif;

text-align: center; }

h2{ font-family:sans-serif;

font-style:italic;

text-align: left; }

p { font-family: sans-serif;

font-size: 12px;}

</style>

<h1 align = “center”> Order Form</h1>

<form action =”/formtest.php” onsubmit=” returnvalidateForm()” id=”myForm” >

<label for=”lblitems”>Three items are available:<br> </label> 1. Planer <br> 2. Chisels<br> 3. Pitchfork </br></br> </label>

<label for =”planerlb”> Number of $5.99 Planers</label> <input id=”numOfPlan” type=”text” name=”planerlb” value=”0″ ></br></br>
<label for =”chisellb”> Number of $2.99 Chisels</label> <input id=”numOfChisels” type=”text” name=”chisellb” value=”0″></br></br>
<label for =”pitchlb”> Number of $8.99 Pitchforks</label> <input id=”numOfPitchforks” type=”text” name=”pitchlb” value=”0″></br></br>

Please fill the following details: </br> </br>
Customer Name: <input type=”text” customername=”name”><br><br>
Shipping Address : <input type=”text” <textareaname=”shipaddress” rows=”5”cols=”25”</textarea><br></br>

<label for = “lblPayt”>Please Select Payment Method:<label> <br></br>
<input type=”radio” name=”payment” value=”Visa” checked>Visa<br>
<input type=”radio” name=”payment” value=”MasterCard”>MasterCard<br>
<input type=”radio” name=”payment” value=”American Express”>American Express
</br>

</br>

</br>

<center>

Click Submit to Finish Your Order<br>

<input type=”submit” value=”Submit” ></center>

</form>

</body>

</html>

Expert Answer


Answer to Copy your form from Lab Exercise6 to l7p1.php and change it to read the states from a database table instead of putting … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *