我一般是这么做的(php/myql web)
简化一下 假设 有这样一个查询语句我想把国家代码和国家名称放到下拉菜单数据库表名是country
$query="select country_code,country_name from countries";
//... 执行查询
//...得到结果$result
if (mysql_num_rows($result)>0)
{
echo "<select name=country><option value="">--选择国家名称--</option>\n";
    while ($row=mysql_fetch_array($result))
     {
         echo "<option value=".$row[country_code].">".$row[country_name]."</option>";
     }
echo "</select>";
}你要的是不是这样的东西?

解决方案 »

  1.   

    你的我看不但我都使用循环的
    <select name = "select"></select>
    <?php while(.....){?>
    <option value = "<?php echo data?>"><?php echo data..?></option>
    <?php
    }?>
    </select>
      

  2.   

    你的我看不懂,我都使用循环的
    <select name = "select"></select>
    <?php while(.....){?>
    <option value = "<?php echo data?>"><?php echo data..?></option>
    <?php
    }?>
    </select>
      

  3.   

    <SCRIPT language=JavaScript1.2>
    function MM_goToURL() { 
    var i, args=MM_goToURL.arguments; document.MM_returnValue = true ;
    for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    }
    </script>
            <select name="select" onChange="MM_goToURL('self',this.value);return document.MM_returnValue">
              <? $study_sql="select * from manager_group where group_type_id='$view_group_id'";
    $study_query=mysql_query($study_sql);
    while($study_result=mysql_fetch_array($study_query)){
    $diseable="";
    if($study_id!=""){
    if($study_result["id"]==$study_id) $diseable="selected";
    }
    echo "<option value=right.php3?study_name=".$study_result["manager_name"]."&study_id=".$study_result["id"]." ".$diseable." >".$study_result["manager_name"]." </option>";
    }
    ?>
            </select> 
    MM_goToURL是选择响应