Drop down menu, fetch from database

how do i get a drop down menu to fetch items from a database?


<form action="Register.php" method="post"> 

<p>Select: <input type="text, number" name="Select" size="20" maxlength="80" value="<?php if (isset($_POST['Select'])) echo $_POST['Select']; ?>"  /> </p>
	
<p><input type="submit" name="submit" value="GO!" /></p>
<input type="hidden" name="submitted" value="TRUE" />

</form>


How would i do this with a drop down menu?

Depends on some things:

1.) Adapter Choice (std. mysql, mysqli, pdo)
2.) Database Table (the table schema preferably)
3.) The table columns that will be used for the value and label of each option

Once you post that info an exact answer can be given rather then a generic one.

Your pretty much going to query the database for what you want and loop through that data to display the options. However, the implementation details of that process depends entirely on the information outlined above.

Another thing to note is that there is no input type of text, number. In HTM5 I believe you can declare a number, but the only options in the industry standard, 4.0 are pretty limited. However, in the case that your creating a list of options the appropriate element to use would be a select not an input.

  1. create your <select> (drop down)

  2. when the submit button is clicked. the value of the option selected by the user is sent to your server side script.

  3. use that selected value in 2) to run a query to fetch the appropriate items from your database