Page 1 of 1

Populating a select form input tag with mysql data

Posted: Thu May 16, 2002 8:04 pm
by dickey
How do I populate a select (drop list) on a form using data from a single column from a mysql table, so that each row in the column becomes an option in the select (drop list).

Any assistance will be greatly appreciated

Posted: Thu May 16, 2002 9:01 pm
by DSM

Code: Select all

<select name = "select">
<?
$sql = mysql_query("SELECT  * FROM table");
while($result = mysql_fetch_array($sql)):
$info = $result&#1111;"info"];
echo"<option value = "$info">$info</option>";
endwhile;
?>
</select>
Hope this helps