繁体   English   中英

能够检查表单元格NOT是否等于null,如果是,则删除/隐藏单元格中的按钮

[英]Able to check if the table-cell NOT equals null, if so remove/hide button in the cell

我想知道是否有可能隐藏按钮,如果表格单元格中有某种信息,或者行(技术人员)不等于“ NULL”。 如果单击1次后没有任何用处,那会有点烦人。

我的数据库(表名:assignment):

| ID | CustomerID | Name | Address | Technician |

我的PHP:

<?php 
if(isset($_POST['customerButton'])){
    $ID = $_POST['assignment_id'];
    $user = $row_Users['username']; <--- // Name of the logged in user.

    mysql_query("UPDATE assignment SET technician = '$user' WHERE ID='$ID'"); <--- //Not sure what to put after 'WHERE'. 
}

?>

这是动态表的一小段

<td><?php echo $row_Assignment['address']; ?></td>
<td>
<?php echo $row_Assignment['technician']; ?>

<form action="" method="post"> 

    <input type="hidden" name="assignment_id" value="".$row_Assignment['ID']."">                                 
    <input type="submit" name="customerButton" id="customerButton" value="Add">

</form>
</td>

谢谢!

编辑:上面代码的目的是让我的一名技术人员能够进行作业。 当他们按下按钮时,数据库UPDATE的行即已完成分配的表格单元中就不需要按钮了。

在数据库中的一列中管理名为is_taken的按钮状态。 并在技术人员单击按钮时更新此列。 渲染HTML时,请检查is_taken列的状态。 现在,您的html将如下所示:-

<td><?php echo $row_Assignment['address']; ?></td>
<td>
<?php echo $row_Assignment['technician'];
   if($row_Assignment['is_taken']==0){ ?>
    <form action="" method="post"> 
      <input type="hidden" name="assignment_id" value="".$row_Assignment['ID']."">                                 
      <input type="submit" name="customerButton" id="customerButton" value="Add">
<?php }
  else{
         // do as you want to replacing with button
      }
?>
   </form>
</td>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM