Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 3; Using PHP to generate forms: To your order form from Part 2, add input e

ID: 3813006 • Letter: P

Question

Part 3; Using PHP to generate forms: To your order form from Part 2, add input elements for customer name and address if they're not already there. The "state" part of the address must be a select element(also called a "pulldown menu") to allow the person placing the order to choose his or her state. Don't type all fifty states, but supply at least Georgia, Alabama and Florida. Put the names of the states in an PHP array and use PHP code to create the drop-down dynamically. (This will still be named l6p2.php; you're just adding to something you've already tested.) You will find an example of creating a select element for states in the class slides covering HTML forms. You are going to create the drop-down dynamically, and not by hard-coding it. This part of the assignment is a fair example of something you might do with PHP in "real life." Instead of an array, you would use a database call, so if we suddenly add another state to the U.S. (or your company suddenly adds another state to its service area) a change to the database automatically (and immediately) changes what people see in the form. For this assignment, you're loading states from an array. We'll get them from a database in the next assignment.

Explanation / Answer

HI, you have not provided Part 2 of the problem, so its not clear what is the application and what are the table details. So I am just providing a sample code to add a dynamic dropdown in PHP. You can use this as a direction to implement in your application. I hope this is what you want. $select_query= "Select state_name from state"; $select_query_run = mysql_query($select_query); echo ""; while ($select_query_array= mysql_fetch_array($select_query_run) ) { echo "".htmlspecialchars($select_query_array["state_name"]).""; } echo "";