PHP select box help

Associate
Joined
5 Feb 2006
Posts
129
Location
Birmingham
I want to fill a select box with results from db eg:

Code for select box:

<form id="form1" name="form1" method="post" action="">
<label>
<select name="select">
<option value="userid">User Name</option>
</select>
</label>
</form>

Code to get userid from db:

while($row = mysql_fetch_array($result))
{
echo $row['id'] . " " . $row['name'];
echo "<br />";
}


I need to join them together

The only problem is i cant find any tutorials on the web and it's beyond my current ability so i cant work it out? Dose any one have a code example i could look at please!

Thank You
 
I haven't tested this but the form needs to looks something like this:

Code:
<form id="form1" name="form1" method="post" action="">
<label>
<select name="select">
<?php>
while($row = mysql_fetch_array($result))
{
echo "<option value=\"". $row['id'] . "\">" . $row['name'] . "</option>";
}
?>
</select>
</label>
</form>
 
Last edited:
Back
Top Bottom