如果数据表中的单元格是字段,则禁用文本区域和按钮



如果数据库中存在bank_EMP_ID,我想禁用下面代码中的文本字段"ICICI BM/DBM EMP_ID"one_answers"APPROVE"按钮?这意味着,如果数据库中存在bank_emp_id,则用户将无法在文本区域中输入任何输入,并且按钮将保持禁用状态;如果不存在id,则文本字段和按钮将保持启用状态。

请尽快提供帮助。

<?php
include 'includes/header.php';


if(htmlspecialchars(isset($_GET['sid'])))
{
$sid=htmlspecialchars($_GET['sid']);
$sql="SELECT * FROM branchdetail WHERE solID= '{$sid}' ORDER BY id DESC LIMIT 1 ";
$result=mysqli_query($connection,$sql);
while($row=mysqli_fetch_assoc($result)){
?>
<section id="services">
<div class="container">
<div class="col-sm-12">
<table class="table table-bordered">
<thead>
<tr><th align="center" colspan="6">Park Telesolutions Pvt. Ltd.</th></tr>
<tr>
<th colspan="3">Corporate Office: BlockAQ, Plot No.-12,Sec-V, Salt Lake, Kolkata-700091</th>
<th colspan="3">Registered Office: 9/8, Netaji Nagar, Kolkata-700092</th>
</tr>
<tr>
<th colspan="2">Website:- www.parkgroup.co.in</th>
<th colspan="2">Phone No.:- (033)6500 2963/64</th>
<th colspan="2">Email:- info@parkgroup.co.in</th>
</tr>
<tr><th align="center" colspan="6">Installation & Commissioning Report</th></tr>
<tr>
<th colspan="1">Sol ID-<?php echo $row['solID']?></th>
<th colspan="2">Branch Name-<?php echo $row['branchName']?></th>
<th colspan="3">Branch Address-<?php echo $row['branchAddress']?></th>
</tr>
<tr>
<th colspan="1">SL.NO</th>
<th colspan="2">Material Description</th>
<th colspan="1">UOM</th>
<th colspan="1">BOQ QTY</th>
<th colspan="1">Installed QTY</th>
</tr>
<?php
$sql="SELECT * FROM imc WHERE solID= '{$sid}' ORDER BY id DESC LIMIT 1";
$result= mysqli_query($connection,$sql);
while($row=mysqli_fetch_assoc($result)){
?>
<tr>
<th colspan="1">1</th>
<th colspan="2"><?php echo $row['camera']?></th>
<th colspan="1">NOS</th>
<th colspan="1"><?php echo $row['cameraqty']?></th>
<th colspan="1"><?php echo $row['cameraqty']?></th>
</tr>
<tr>
<th colspan="1">2</th>
<th colspan="2"><?php echo $row['dvr']?></th>
<th colspan="1">NOS</th>
<th colspan="1"><?php echo $row['dvrqty']?></th>
<th colspan="1"><?php echo $row['dvrqty']?></th>
</tr>
<tr>
<th colspan="1">3</th>
<th colspan="2"><?php echo $row['harddisk']?></th>
<th colspan="1">NOS</th>
<th colspan="1"><?php echo $row['harddiskqty']?></th>
<th colspan="1"><?php echo $row['harddiskqty']?></th>
</tr>
<tr>
<th colspan="1">4</th>
<th colspan="2"><?php echo $row['monitor']?></th>
<th colspan="1">NOS</th>
<th colspan="1"><?php echo $row['monitorqty']?></th>
<th colspan="1"><?php echo $row['monitorqty']?></th>
</tr>
<tr>
<th colspan="1">5</th>
<th colspan="2"><?php echo $row['smps']?></th>
<th colspan="1">NOS</th>
<th colspan="1"><?php echo $row['smpsqty']?></th>
<th colspan="1"><?php echo $row['smpsqty']?></th>
</tr>
<tr>
<th colspan="1">6</th>
<th colspan="2"><?php echo $row['cameracable']?></th>
<th colspan="1">Per Mtr.</th>
<th colspan="1"><?php echo $row['cameracableqty']?></th>
<th colspan="1"><?php echo $row['cameracableqty']?></th>
</tr>
<tr>
<th colspan="1">7</th>
<th colspan="2"><?php echo $row['camerapowercable']?></th>
<th colspan="1">Per Mtr.</th>
<th colspan="1"><?php echo $row['camerapowercableqty']?></th>
<th colspan="1"><?php echo $row['camerapowercableqty']?></th>
</tr>
<tr>
<th colspan="1">8</th>
<th colspan="2"><?php echo $row['conduitpipe']?></th>
<th colspan="1">Per Mtr.</th>
<th colspan="1"><?php echo $row['conduitpipeqty']?></th>
<th colspan="1"><?php echo $row['conduitpipeqty']?></th>
</tr>

<tr>
<th colspan="4">I&C Report No.- <?php echo $row['POno']?></th>
<th colspan="2">DATE- <?php echo $row['date']?></th>
</tr>
<tr>
<th colspan="3">PARK Emp_ID- <?php echo $row['park_emp_id']?></th>
<th colspan="3">ICICI BM/DBM Emp_ID- <?php echo $row['bank_emp_id']?></th>
</tr>
<?php
}}}
?> 
</thead>
</table>
</div>
</div>
</section>
<div class="col-sm-12">
<form class="" action="" method="post">
<div class="form-group">
<label for="comment">ICICI BM/DBM EMP_ID:</label>
<input type="text" class="form-control" id="bank_emp_id" name="bank_emp_id" required="require" placeholder="Please Enter Your ICICI EMP-ID">
</div><br>
<button type="submit" class="btn btn-default" name="submit">Approve</button>
</form>
<div class="col-sm-8 col-sm-offset-2 text-right">
<h4><a href="home.php?solid=<?php echo $sid;?>">Back</a></h4>
</div>
<br><br><br><br>
<?php   
if(htmlspecialchars(!isset($_POST['submit']))){
//header('Location:create_bmDbm.php');
}else{
$bank_emp_id=htmlspecialchars($_POST['bank_emp_id']);
$sql="UPDATE imc SET bank_emp_id='{$bank_emp_id}'";
$sql.=" WHERE solID='{$sid}' ORDER BY id DESC LIMIT 1";
$result=mysqli_query($connection,$sql);
if(!$result){
echo 'ERROR'.mysqli_error($connection);
}else{
header('Location:sensor_detail.php?sid='.$sid.'&bank_emp_id='.$bank_emp_id);
}
}
?>
</div>
<?php    include 'includes/footer.php'; ?> 

尝试使用以下代码HTML:<input type="text" onkeyup="checkAvailability(this);" class="form-control" id="bank_emp_id" name="bank_emp_id" required="require" placeholder="Please Enter Your ICICI EMP-ID">

Jquery/Ajax:

<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function checkAvailability(e) {
var check = $("#bank_emp_id").val();
jQuery.ajax({
url: "check.php",
data:'check='+check,
type: "POST",
success:function(data){
if(data=="Exist"){
$("input").attr('disabled',true);
}else{
$("input").attr('disabled',false);
}
},
error:function (){}
});
}
</script>

检查.php

// include your connection file
if(!empty($_POST['check'])){
$check=$_POST['check'];
$query=mysqli_query($conn,"SELECT bank_emp_id FROM your_table_name WHERE bank_emp_id='$check'");
$numrows=mysqli_num_rows($query);
if($numrows > 0){
echo "Exist";
}else{
echo "";
}
}

最新更新