dourao1877 2018-08-12 11:08
浏览 25

PHP $ _POST ['xxx']问题

this line in booktime.php does not work

if(isset($_POST['hair'])){
            $hair=$_POST['hair'];
            $query="SELECT first_name,last_name FROM employee_info e, employee_hair_service h WHERE e.e_id=h.e_id AND h.s_id=".$hair;
            $query_result=mysqli_query($con,$query);
            while($result_row=mysqli_fetch_array($query_result)){
                echo " <option value='-Select-'>".$result_row[0].$result_row[2]."</option>";
            }
        }

i wanted to add options to dresser select box once the user chooses the 'hair' select box but it does not work

book.php

<script>
$(document).ready(function(){
    $('.book_btn').click(function(){
        var colIndex=$(this).index();
        var day = $(this).closest("tr").find("td:eq(0)").text();
        $.post("booktime.php",{
            time: day,
        }, function(data,status){
            $("#book_time").html(data);
        });
    });
});

</script>

booktime.php

<?php
    $con=mysqli_connect('localhost','root','','hair_salon');
    if(isset($_POST['time'])){
        $time=$_POST['time'];
        echo "<form method='post'><table>
            <tr>
                <td>Time</td>
                <td>".$time."</td>
            </tr>
            <tr>
                <td>Service</td>
                <td>
                    <select name='hair'>
                        <option selected='selected' value='-Select-'>-Select-</option>";

        $con=mysqli_connect('localhost','root','','hair_salon');
        $query = "SELECT s_id,s_name FROM hair_service";
        $query_result=mysqli_query($con,$query);
        while($result_row=mysqli_fetch_array($query_result)){
            $s=$result_row[0];
            $h=$result_row[1];
            echo "<option value=".$s.">".$h."</option>";
        }

        echo        "</select>
                </td>
            </tr>
            <tr>
                <td>HairDresser</td>
                <td>
                    <select name='dresser'>;
                        <option selected='selected' value='-Select-'>-Select-</option>";

        if(isset($_POST['hair'])){
            $hair=$_POST['hair'];
            $query="SELECT first_name,last_name FROM employee_info e, employee_hair_service h WHERE e.e_id=h.e_id AND h.s_id=".$hair;
            $query_result=mysqli_query($con,$query);
            while($result_row=mysqli_fetch_array($query_result)){
                echo " <option value='-Select-'>".$result_row[0].$result_row[2]."</option>";
            }
        }

        echo        "</select>
                </td>
            </tr>
        </table></form>";
    }
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?