populate the drop down list on html with data from the dbase
Posted: Tue Mar 10, 2009 4:35 am
How to populate the drop down list on html with data from the database
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Query the database and use PHP to create an html drop down list.lodae wrote:How to populate the drop down list on html with data from the database
Code: Select all
<select name="field_name">
<?PHP
$getData = "SELECT * FROM table_name";
$getData_q = mysql_query($getData, $connection);
while($getData_r = mysql_fetch_assoc($getData_q)) {
?>
<option value="<?PHP echo $getData_r['field']; ?>"><?PHP echo $getData_r['field']; ?></option>
<?PHP
}
?>
</select>