PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
S_henry
Forum Contributor
Posts: 148 Joined: Sun Jan 25, 2004 10:25 pm
Location: M'sia
Post
by S_henry » Sun Apr 11, 2004 9:03 pm
How to put/display a list of data from table into a list box? Anybody has any idea pls?
qads
DevNet Resident
Posts: 1199 Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane
Post
by qads » Sun Apr 11, 2004 9:35 pm
Code: Select all
<select name="bla" size="1">
<?php
$query = mysql_query("select field1, field2 from table");
while($data =mysql_fetch_array($query))
{
echo '<option value="'.$data['field1'].'">'.$data['field2'].'</option>';
}
?>
</select>
S_henry
Forum Contributor
Posts: 148 Joined: Sun Jan 25, 2004 10:25 pm
Location: M'sia
Post
by S_henry » Mon Apr 19, 2004 3:01 am
Thanx qads.