如果从数据库中获取数据,如何调用函数!=“Detained”

时间:2018-05-09 14:13:07

标签: javascript php mysql

我从数据库中获取数据并回复它。一旦我进入囚犯的个人资料并且他的状态未被拘留,应该自动禁用“添加访客”按钮。

我应该在哪里调用disable()函数来调用它?

这是我的剧本

<script language = "javascript" type = 'text/javascript'>
function disable(){

            if(document.getElementById('prisonerstatus').value == "Detained"){
            document.getElementById("visitorbtn").disabled= false;}
            else{
                document.getElementById("visitorbtn").disabled= true;
            }

    };
</script>

PHP

<?php
include "connect.php";
$idd =$_GET['id'];
$result = $connect->query("SELECT * FROM prisoner 
                            INNER JOIN offensedata ON prisoner.prisoner_id = offensedata.prisoner_id
                            INNER JOIN arrestdata on prisoner.prisoner_id = arrestdata.prisoner_id 
                            INNER JOIN booking ON prisoner.prisoner_id = booking.prisoner_id
                            WHERE prisoner.prisoner_id = $idd") or die($connect->error);

$rows1 = $result->fetch_all(MYSQLI_ASSOC);

foreach ($rows1 as $row){

$status = $row['status'];

echo "<input type = 'hidden' value = '$status' id = 'prisonerstatus'/>";

            echo "<div class='col-lg-3'>Status: $status </div>";
}

这是我的按钮

<input type = "button" class="call_modal" style="cursor:pointer;margin-top:1%;" value = "Add Visitor" id = 'visitorbtn'>

请原谅我的代码。这仅适用于我的学校项目,这些代码是我们所教授的。我将研究如何避免SQL注入并尽快应用它。提前谢谢你:)

0 个答案:

没有答案