0

我试图在以下代码的下拉列表中显示价格,但它显示的是产品名称而不是价格:

<?php
  //-----------------------PROCESSOR---------------------------
    $query="SELECT product_name, price FROM processor";
    $result = mysql_query($query);
    $options="";
    echo "<select name='processor' value=''>
    <option>Please Select A Processor</option>";

    while($nt=mysql_fetch_array($result))
    {
      echo "<option value='".$nt['price']."'>".$nt['product_name']."</option>";
    }
    echo "</select>";
?>

谁能帮助我做错了什么?

提前致谢!

4

1 回答 1

1

只需更换

echo "<option value='".$nt['price']."'>".$nt['product_name']."</option>";

echo "<option value='".$nt['price']."'>".$nt['price']."</option>";

看看文档: http ://www.w3schools.com/tags/tag_option.asp

于 2013-03-30T17:09:57.323 回答