Php 单击mysqli中的另一个按钮后显示按钮
我在index.php中有以下代码:Php 单击mysqli中的另一个按钮后显示按钮,php,button,mysqli,Php,Button,Mysqli,我在index.php中有以下代码: <?php require 'class.php';require_once './session.php';$conn = new db_class();$read = $conn->read();$data = [];while($fetch = $read->fetch_array()){ $data[] = $fetch;}?> <table class = "table table-bordered table-
<?php require 'class.php';require_once './session.php';$conn = new db_class();$read = $conn->read();$data = [];while($fetch = $read->fetch_array()){
$data[] = $fetch;}?>
<table class = "table table-bordered table-responsive ">
<thead>
<tr>
<th>Segment</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($data as $fetch): ?>
<tr>
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id']?>">
<td class="segment" contenteditable="true"><?= $fetch['segment'] ?></td>
<td class="text-center">
<button class = "btn btn-default action-btn" data-id="<?= $fetch['id'] ?>" data-action="update">
<span class = "glyphicon glyphicon-edit"></span> Update
</button>
|
<button class = "btn btn-success action-btn" data-id="<?= $fetch['id'] ?>" type="submit" data-action="activate">
<span class = "glyphicon glyphicon-check"></span> Activate
</button>
|
<button class = "btn btn-danger action-btn" data-id="<?= $fetch['id'] ?>" data-action="deactivate">
<span class = "glyphicon glyphicon-folder-close"></span> deactivate
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
我只想显示是否禁用激活以仅显示激活按钮,如果启用激活以仅显示停用按钮,
我使用0表示停用,1表示启用首先需要隐藏停用按钮使用
样式
显示
隐藏
按钮在activate按钮上写入click事件,然后使用jquery隐藏activate按钮并显示deactivate按钮
$(“.activate btn”)。单击(函数(){
$(this.hide();
$(“.deactivate btn”).show();
});代码>
段
行动
您如何确定该按钮是否已激活。db有什么信息吗?是的,我有一个名为segment的表,其中defaut激活为1,因此我只想显示deactivate按钮,单击它后,我想显示activate按钮@Omi
public function read()
{
$stmt = $this->conn->prepare("SELECT id,segment FROM `segments`") or die($this->conn->error);
if ($stmt->execute()) {
$result = $stmt->get_result();
return $result;
}
}