This is my function to do what I understand you are trying to do.
It references some other functions but I hope they are pretty obvious what they do. The essence of creating the drop down list is here.
You just call this function and then echo the result string that is returned.
function create_drop_down_box_from_mysql($table_name, $ffn, $ud, $select_name,$key_field_name, $text_field_name)
{
// This function looks up $table_name
// The where clause is "WHERE $ffn = '$ud'";
// then it loops through the returned data and builds a HTML drop down box
//
// <SELECT name='drop_down_bom_name'>
// <OPTION value='value 1' " selected">text 1</OPTION>
// <OPTION value='value 2' selected>text 2 bla bla</OPTION>
// </SELECT>
$result = query_mysql_return_handle($table_name, $ffn, $ud); // general_functions
$num_results = mysqli_num_rows($result);
// 2. Initialise
$my_string = "<SELECT id='$select_name' name='$select_name'>";
// 3. Loop through the results and populate
for($i=1; $i<=$num_results; $i++)
{
$row = get_row_and_clean_up($result); // strips off slashes and other non printable characters
$key = $row[$key_field_name];
$text = $row[$text_field_name];
//print_array_recursive($row);die(); // debugging
$my_string = $my_string."\n<OPTION value='$key'>$text</OPTION>";
};
$my_string = $my_string."\n</SELECT>";
//echo "\n<BR>$my_string"; die();
return $my_string;
}