web forms help

Soldato
Joined
1 Feb 2006
Posts
8,188
hi, not sure if this is possible but will give it a go. I have a web form on my webpage and i want to include a few drop down menus on it. Is it possible to look up a database and display every result as one option in my drop down menu? i.e. if there are 4 items in the database i want each one to be an option in the drop down menu?
 
jonnyc747 said:
hi, not sure if this is possible but will give it a go. I have a web form on my webpage and i want to include a few drop down menus on it. Is it possible to look up a database and display every result as one option in my drop down menu? i.e. if there are 4 items in the database i want each one to be an option in the drop down menu?

What database are you using? Quite easily done in PHP and MySQL but if you're not using those languages when it's not much use :p
 
Right well you can do something like this then:

Code:
<form action="form.php" method="post">

<select name="options">
<?php

$getoptions = mysql_query("SELECT * FROM options");

while ($getoptions = mysql_fetch_array($getoptions)) {

$optionvalue = $getoptions['optionvalue'];
$optionname = $getoptions['optionname'];

echo "<option value='$optionvalue'>$optionname</option>";

}

?>

</form>

:)
 
Back
Top Bottom