选择第一个选项后,从数据库中选择option2值

时间:2014-04-04 13:53:01

标签: javascript php mysql

我有以下表格:

 <form action="" method="post" target="_self">
             <div id="qcategory_1">Product</div>
             <div id="qcategory">
               <select name="Category" class="dropmenu" id="Category">
                 <option value="">Any</option>
                 <option value="Keyboard"<?php if ($_POST['Category']=="Keyboard") {echo "selected='selected'"; } ?>>Keyboard</option>
                 <option value="Piano"<?php if ($_POST['Category']=="Piano") {echo "selected='selected'"; } ?>>Piano</option>
               </select>
             </div>
             <div id="qbrand_1">Brand</div>
             <div id="qbrand">
               <select name="Manufacturer" class="dropmenu">
               <option>Any</option>
              <script type="text/javascript">   $("#Category").change(function() {
    $("#Manufacturer").load("Menubackend.php?choice=" + $("#Category").val());
});</script>
               </select></form>

后端填充如下:

<?php require_once('Connections/dconn.php'); ?>
<?php
$Category=$_POST['Category'];


    $choice = mysql_real_escape_string($_POST['choice']);

    $query = "SELECT DISTINCT Manufacturer FROM products WHERE Category LIKE '$choice'";

    $result = mysql_query($query);

    while ($row = mysql_fetch_array($result)) {
        echo "<option>" . $row{'products'} . "</option>";
    }




?>

我正在尝试将制造商作为第二个下拉菜单的选项值显示基于第一个,但是这似乎根本无法从数据库中检索任何值。 任何建议欢迎

0 个答案:

没有答案