populate the drop down list on html with data from the dbase
Moderator: General Moderators
populate the drop down list on html with data from the dbase
How to populate the drop down list on html with data from the database
Re: populate the drop down list on html with data from the dbase
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
Re: populate the drop down list on html with data from the dbase
This is a very basic way:
<select name="drop_down">
<option value="">Select from list</option>
<?php
while($row = mysql_fetch_array($rsquery))
{?>
<option value="<?php echo $row['var1'];?>"><?php echo $row['var2'];?></option>
<?php
}?>
</select>
Hope thats something useful.
<select name="drop_down">
<option value="">Select from list</option>
<?php
while($row = mysql_fetch_array($rsquery))
{?>
<option value="<?php echo $row['var1'];?>"><?php echo $row['var2'];?></option>
<?php
}?>
</select>
Hope thats something useful.
-
Paul Arnold
- Forum Contributor
- Posts: 141
- Joined: Fri Jun 13, 2008 10:09 am
- Location: Newcastle Upon Tyne
Re: populate the drop down list on html with data from the dbase
Here's an example
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>