由if语句触发的模态表单

时间:2017-05-15 00:26:25

标签: javascript php jquery html bootstrap-modal

所以我正在构建一个网页,以及其中的所有内容,但有一件事情很好。 所以在我的“MDT”页面上,我选择一个状态(例如状态0,它发送“恐慌按钮”),并将其发送到数据库。当control.html检查数据库(每秒),并选择“状态”列说“紧急按钮”时,它会发出警报。当我的状态发生变化时,该警报就会结束。

我想要的是一个警报,一个弹出基本细节的模态表格(例如活动状态0,呼号,姓名等)

到目前为止:

<center><h2>Available Units</h2>
                    <div id="units">
                        <ul class="units">
                            <?php
                                $sql = "SELECT * FROM mdt WHERE CAD = 'NULL';";
                                $result = mysqli_query($link, $sql);
                                while ($row = mysqli_fetch_array($result)) {
                                    echo '<li class="' . statusToClass(displayData($row['status'])) . '">' . displayData($row['callsign']) . ' - ' . displayData($row['name']) . ' <span class="glyphicon glyphicon-cog editUnitBtn" aria-hidden="true"></span><br/>Status: ' . displayData($row['status']) . '</li>';
                                }
                            ?>
                            <?php
                                $sql = "SELECT * FROM mdt WHERE status = 'Panic Button';";
                                $result = mysqli_query($link, $sql);
                                if ($row = mysqli_fetch_array($result)) {
                                    echo '<audio autoplay="false" src="panic.mp3">';
                                    sleep(2);
                                    }
                            ?>
                            <?php
                                $sql = "SELECT * FROM mdt WHERE status = 'Panic Button';";
                                $result = mysqli_query($link, $sql);
                                if ($row = mysqli_fetch_array($result)) {
                                     echo "<script>$('#panicModal').modal('show')</script>";
                                     }
                            ?>

然后靠近页面底部:

    <div class="modal fade" id="panicModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">ATTENTION - ACTIVE STATE 0</h4>
        </div>
        <div class="modal-body">
        <?php
        $sql = "SELECT * FROM mdt WHERE status = 'Panic Button';";
        $result = mysqli_query($link, $sql);
        $row = mysqli_fetch_array($result);
        ?>
        <label>Callsign</label>
        <?php echo displayData($row['callsign']); ?>
        <Label>Collar Number</label>
        <?php echo displayData($row['name']); ?> 
        <Label>Last Known Location</label>
        <?php   
        if (displayData($row['CAD']) == "NULL") {
        echo ' <i>Currently unassigned</i>';
        } else {            
        $cadid = displayData($row['CAD']);
        $sql = "SELECT * FROM cads WHERE id = '$cadid';";
        $result = mysqli_query($link, $sql2);
        $row = mysqli_fetch_array($result2);
        echo displayData($row['location']); } ?> 
        <Label>Call Type</label>
        <?php           
        if (displayData($row['CAD']) == "NULL") {
        echo ' <i>Currently unassigned</i>';
        } else {
        $cadid = displayData($row['CAD']);
        $sql2 = "SELECT * FROM cads WHERE id = '$cadid';";
        $result2 = mysqli_query($link, $sql2);
        $row2 = mysqli_fetch_array($result2);
        echo displayData($row['type']); } ?> 
        </div>    
    </div>
</div>

任何想法?在互联网的某个地方,它提到将jquery放在页面的顶部,但是当我这样做时它没有任何区别,取决于我把它放在哪里,停止所有js功能工作。然而,底部的jquery脚本,这一切都很好。

control.html:https://pastebin.com/9u6Su1uD control.js:https://pastebin.com/1FeXUN6b

非常感谢任何帮助。 TIA 泰勒

0 个答案:

没有答案