Question
Part 1; From databases to forms: read the states from a database table instead of putting them into a PHP array yourself.(the php file is
Part 1; From databases to forms: read the states from a database table instead of putting them into a PHP array yourself.(the php file is included down below)
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
element. The form area 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_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;
this is my php file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started