Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Preencher o menu suspenso de seleção de uma tabela de banco de dados

$query = "SELECT volunteers_2009.id, volunteers_2009.comments, volunteers_2009.choice1, volunteers_2009.choice2, volunteers_2009.choice3, volunteers_2009.lname, volunteers_2009.fname, volunteers_2009.venue_id, venues.venue_name FROM volunteers_2009 AS volunteers_2009 LEFT OUTER JOIN venues ON (volunteers_2009.venue_id = venues.id) ORDER by $order $sort";

$res = mysql_query($query);
echo "<select name = 'venue'>";
while (($row = mysql_fetch_row($res)) != null)
{
    echo "<option value = '{$row['venue_id']}'";
    if ($selected_venue_id == $row['venue_id'])
        echo "selected = 'selected'";
    echo ">{$row['venue_name']}</option>";
}
echo "</select>";