I was wondering if it is possible to run a query on a table and then have the results returned to a combo box for a user to select.
What I want to do is when a user enters information about a house on a form they have a combo box which they can click on and select a development name if the house is part of that development.
So the combo box would list all the developments and when the user selects one and submits the form, the id of the development would be added to a field in the houses table.
Any code guiding me in the right direction would be much appreciated.
Thanks
okee
Sending query result to a combo box
Moderator: General Moderators
- Heavy
- Forum Contributor
- Posts: 478
- Joined: Sun Sep 22, 2002 7:36 am
- Location: Viksjöfors, Hälsingland, Sweden
- Contact:
this is how you set default data of a select element:
Code: Select all
<?php
// some data:
$arrWithData = Array(Array('val' => 12, 'textval' => 'twelve'),Array('val' => 12, 'textval' => 'twelve'));
$options = '':
foreach ($arrWithData as $Data){
$options .= '<option value="' . $Data['val'] . '">' . $Data['textval'] . '</option>';
}
?>
<html>
<form>
<select name="selectelement">
<?php echo $options ?>
</select>
</form>
</html>