List box

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

Post Reply
S_henry
Forum Contributor
Posts: 148
Joined: Sun Jan 25, 2004 10:25 pm
Location: M'sia

List box

Post by S_henry »

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 »

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 »

Thanx qads. :D
Post Reply