Предположим, ваш стол выглядел так
mysql> select * from FRUITS;
+---------+-----------+
| fruitid | fruitname |
+---------+-----------+
| 1 | Orange |
| 2 | Apple |
| 3 | Pear |
| 4 | Banana |
+---------+-----------+
4 rows in set (0.02 sec)
Ваш код должен выглядеть примерно так:
<?php
$conn = mysql_connect('localhost','yourUsernameHere','yourPasswordHere');
mysql_select_db('testdb',$conn);
$query = "select fruitid,fruitname from FRUITS order by fruitname";
$result = mysql_query($query,$conn);
$selectbox='<select name=\'fruit\'>';
while ($row = mysql_fetch_assoc($result)) {
$selectbox.='<option value=\"' . $row['fruitid'] . '\">' . $row['fruitname'] . '</option>';
}
$selectbox.='</select>';
mysql_free_result($result);
echo $selectbox;
?>