从数据库中提取数据时创建下拉列表


creating a drop down list when pulling data from a database

hi我想在下拉列表中显示我从数据库中提取的类别。目前,他们正在被拉,只是在我创建的菜单栏中显示在一个长行中。到目前为止,我的代码是:

    <?php
    /*
    Displaying List of Categories from the Table - Category and that is limited to 6
    */
    $qry=mysql_query("SELECT * FROM category ", $con);
    if(!$qry)
    {
    die("Query Failed: ". mysql_error());
    }
    /* Fetching datas from the field "category" and article id is transfered to articles.php file */
    while($row=mysql_fetch_array($qry))
    {
    echo "&nbsp;<a href=articles.php?cat=".$row['category'].">".$row['category']."</a>
    &nbsp;&nbsp;&nbsp;&nbsp;";
    }
    ?>

任何帮助都将不胜感激感谢

将while语句更改为:

echo '<select name="list">';
while($row=mysql_fetch_array($qry))
{
    echo '<option>'.$row['category'].'</option>';
}
echo '</select>';