Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将值显示到下拉菜单php_Php - Fatal编程技术网

将值显示到下拉菜单php

将值显示到下拉菜单php,php,Php,我想根据下面的数据库显示下拉列表。(bom表) 例如,当我从下拉列表中选择“表格”时,它将显示bom\u说明、bom\u数量和计量单位 选择产品:表格(下拉列表) (HTML表格将显示这些内容) 当我点击椅子时,它会显示这个 选择产品:椅子(下拉列表) 现在,这是我的代码,但是显示内容的html表没有出现 <script src="script/jquery-1.11.1.min.js"></script> <script>

我想根据下面的数据库显示下拉列表。(bom表)

例如,当我从下拉列表中选择“表格”时,它将显示bom\u说明、bom\u数量和计量单位



选择产品:表格(下拉列表)

(HTML表格将显示这些内容)

当我点击椅子时,它会显示这个

选择产品:椅子(下拉列表)

现在,这是我的代码,但是显示内容的html表没有出现

        <script src="script/jquery-1.11.1.min.js"></script>
        <script>
            $(document).ready(function () {
                $(".itemTypes").change(function () {
                    if (this.value == 0) {
                        $("tr").show();
                    }
                    else {
                        $("tr").hide();
                        $(".header").show();
                        $("." + this.value).show();
                    }
                });
            });
        </script>

    <?php
        session_start();

    if (!isset($_SESSION['username'])) {
        header('location: homepage.php');
    }

    //connect to database
    include ("dbFunctions.php");

    $queryBOM = "SELECT * FROM bom";

    $resultBOM = mysqli_query($link, $queryBOM) or die(mysqli_error($link));
    mysqli_close($link);
    ?>

Select Product:
                            <select class="itemTypes">
                                <option value="0">
                                    all types
                                </option>
                                <?php
                                while ($row1 = mysqli_fetch_array($resultBOM)) {
                                    ?>
                                    <option value="<?php echo $row1['finish_product']; ?>">
                                        <?php echo $row1['finish_product']; ?>
                                    </option>
                                <?php } ?></select>
                            <p>


                                <table border="1">
                                    <tr>
                                        <th>BOM Description</th>
                                        <th>Quantity</th>
                                        <th>UOM</th>
                                        <th colspan="2">Action</th>

                                        <?php
                                        while ($row = mysqli_fetch_assoc($resultBOM)) {
                                            $bom_description = $row['bom_description'];
                                            $bom_quantity = $row['bom_quantity'];
                                            $UOM = $row['UOM'];
                                            ?>

                                            <tr>
                                                <td><center><?php echo $bom_description; ?></center></td>
                                                <td><center><?php echo $bom_quantity; ?></center></td>
                                                <td><center><?php echo $UOM; ?></center></td>
                                                <td><center>
                                                        <form method="post" action="editBOM.php">
                                                            <input type="hidden" name="bomID" value="<?php echo $bom_id; ?>" />
                                                            <input type="image" src="images/editicon.png" name="edit" value="edit" style="width:30px;height:30px;"/>
                                                    </center></form>
                                                </td>
                                                <td><center>
                                                        <form method="post" action="dodeleteBOM.php">
                                                            <input type="hidden" name="bomID" value="<?php echo $bom_id; ?>" />
                                                            <input type="image" src="images/deleteicon.png" name="delete" value="delete" style="width:25px;height:25px;"/>
                                                    </center></form>
                                                    </center></td>
                                                <?php
                                            }
                                            ?>
                                        </tr>

$(文档).ready(函数(){
$(“.itemTypes”).change(函数(){
如果(this.value==0){
$(“tr”).show();
}
否则{
$(“tr”).hide();
$(“.header”).show();
$(“+this.value).show();
}
});
});
选择产品:
所有类型

物料清单说明
量
计量单位
行动

我最初的回答是错误的。 您需要重置在两个循环之间读取结果的点

在完成创建“选择”元素后放置此选项

<?php mysqli_data_seek($resultBOM, 0); ?>

您好,我已经试过了,但是内容没有显示。选择是否已填写?
bom_description |bom_quantity |UOM
Chair Seat        1             /PC
Chair Back        1             /PC
Chair Legs        4             /PC
        <script src="script/jquery-1.11.1.min.js"></script>
        <script>
            $(document).ready(function () {
                $(".itemTypes").change(function () {
                    if (this.value == 0) {
                        $("tr").show();
                    }
                    else {
                        $("tr").hide();
                        $(".header").show();
                        $("." + this.value).show();
                    }
                });
            });
        </script>

    <?php
        session_start();

    if (!isset($_SESSION['username'])) {
        header('location: homepage.php');
    }

    //connect to database
    include ("dbFunctions.php");

    $queryBOM = "SELECT * FROM bom";

    $resultBOM = mysqli_query($link, $queryBOM) or die(mysqli_error($link));
    mysqli_close($link);
    ?>

Select Product:
                            <select class="itemTypes">
                                <option value="0">
                                    all types
                                </option>
                                <?php
                                while ($row1 = mysqli_fetch_array($resultBOM)) {
                                    ?>
                                    <option value="<?php echo $row1['finish_product']; ?>">
                                        <?php echo $row1['finish_product']; ?>
                                    </option>
                                <?php } ?></select>
                            <p>


                                <table border="1">
                                    <tr>
                                        <th>BOM Description</th>
                                        <th>Quantity</th>
                                        <th>UOM</th>
                                        <th colspan="2">Action</th>

                                        <?php
                                        while ($row = mysqli_fetch_assoc($resultBOM)) {
                                            $bom_description = $row['bom_description'];
                                            $bom_quantity = $row['bom_quantity'];
                                            $UOM = $row['UOM'];
                                            ?>

                                            <tr>
                                                <td><center><?php echo $bom_description; ?></center></td>
                                                <td><center><?php echo $bom_quantity; ?></center></td>
                                                <td><center><?php echo $UOM; ?></center></td>
                                                <td><center>
                                                        <form method="post" action="editBOM.php">
                                                            <input type="hidden" name="bomID" value="<?php echo $bom_id; ?>" />
                                                            <input type="image" src="images/editicon.png" name="edit" value="edit" style="width:30px;height:30px;"/>
                                                    </center></form>
                                                </td>
                                                <td><center>
                                                        <form method="post" action="dodeleteBOM.php">
                                                            <input type="hidden" name="bomID" value="<?php echo $bom_id; ?>" />
                                                            <input type="image" src="images/deleteicon.png" name="delete" value="delete" style="width:25px;height:25px;"/>
                                                    </center></form>
                                                    </center></td>
                                                <?php
                                            }
                                            ?>
                                        </tr>
<?php mysqli_data_seek($resultBOM, 0); ?>
mysqli_close($link);