使用PHP中的提交按钮更新多个复选框的值

时间:2019-04-11 07:48:21

标签: php mysql

我正在考虑在我的网站中添加新功能。在我的清单中,我大约有3000个条目。我在每个条目中添加了一个复选框,最后还为该操作添加了一个更新按钮。现在,我只希望当我单击更新按钮时,它将执行操作,但仅对已检查的条目执行。在执行操作时,我只想将已检查条目的状态从“状态= 2”更改为“状态= 0”。默认情况下,每个条目的状态为2。

enter image description here

<div class="container">

<?php 
while($row=mysqli_fetch_assoc($query)){
$id = $row['id'];
$inventorybackground = $row['inventorybackground'];
$inventorycolor = $row['inventorycolor'];
$supplier = $row['supplier'];
$firm_name = $row['firm_name'];
$city = $row['city'];
$reg_date = $row['reg_date'];
$catagory_name = $row['catagory_name'];
$status = $row['status'];
    ?>
<div class="row" style="background-color: <?php echo $inventorybackground; ?> !important; color: <?php echo $inventorycolor; ?>; padding-top: 10px;">

<div class="col-md-1 inventory-data"><input type="checkbox" name="vehicle" value="<?php echo $status; ?>"></div>
<div class="col-md-2 inventory-data"><?php echo $supplier; ?></div>
<div class="col-md-2 inventory-data"><?php echo $firm_name; ?></div>
<div class="col-md-2 inventory-data"><?php echo $catagory_name; ?></div>
<div class="col-md-1 inventory-data"><?php echo $city; ?></div>

<div class="col-md-2 inventory-data"><?php echo $reg_date; ?></div>
<div class="col-md-2 inventory-data">
<button type="button" class="btn btn-success"><a href="delete.php?activate=<?php echo $id; ?>" onclick="return confirm('Are you sure to ?');">Activate</a></button>
<button type="button" class="btn btn-danger"><a href="delete.php?del_new=<?php echo $id; ?>" onclick="return confirm('Are you sure to ?');">Delete</a></button>
</div>

</div>

    <?php } ?>

<center><button type="button" class="btn btn-success"><a href="delete.php?activate=<?php echo $id; ?>" onclick="return confirm('Are you sure to ?');">Update</a></button></center>

</div>

这是我的更新查询:

if ($bulkact=$_GET['bulkact']){
  $bulkact_query="UPDATE inventory_details SET status='0' and today_date='$today_date' where id=$bulkact ";

if ( $run=mysqli_query($conn, $bulkact_query)){

    header("location:index.php?activity=newinventry");
}
}

任何建议都是最欢迎的。 预先感谢。

0 个答案:

没有答案