提问人:Nanak 提问时间:7/21/2023 最后编辑:ADysonNanak 更新时间:7/21/2023 访问量:33
如何将显示表中突出显示的单元格中所做的更改保存到数据库中
HOW do i save changes done in the highlighted cell in the show table into the Database
问:
我想使用如下所示的给定文本框编辑数据库表中的单元格。 最后,我希望能够编辑该给定表中任何行的特定单元格
------------POST 查询
以下是单击更新按钮后更新的 Post 查询
if(isset($_POST['del']))
{
$id=$_GET['del'];
$sql = "DELETE from users WHERE issuingitem_id=:id";
$query = $dbh->prepare($sql);
$query -> bindParam(':id',$id, PDO::PARAM_STR);
$query -> execute();
$msg="Data Deleted successfully";
}
if (isset($_POST['NewQuanty'])){
$acti=$_POST["rqustID"];
$actid=$acti[0];
$query1= $dbh -> prepare("SELECT distinct * FROM requestitem WHERE requestitem_id='$actid' ");
$query1->execute();
while ($row = $query1->fetch()){
$requstITM = $row['requestitem_item']?? '';
$requstCLST = $row['requestitem_cluster']?? '';
$requstNUMB = $row['request_deptcartitm_NUMBER']?? '';
}
$actitmn=$requstITM;
$actclust=$requstCLST;
$actitnmb=$requstNUMB;
$actiapprvn=$_POST["NewQunty"];
$actiapprvno=$actiapprvn[0];
$activate = 1;
//------------EMAIL TRIGGER------------
// include ('../script/emailTRIGGER-script.php');
//------------EMAIL TRIGGER------------
if ($actiapprvno == 0) {
$query1= $dbh -> prepare("UPDATE requestitem set requestitem_approvedNo = (requestitem_no) WHERE requestitem_id=:stffid LIMIT 1");
$query1-> bindParam(':stffid', $actid, PDO::PARAM_STR);
//$query1-> bindParam(':stffactve', $activate, PDO::PARAM_STR);
$query1->execute();
header("location: cluster-request-made.php?deptcluster=$actclust");
}else {
$query1 = $dbh -> prepare("UPDATE itemTABLE SET itemTABLE_acceptance ='$activate' WHERE itemTABLE_deptcartitm_NUMBER='$actitnmb' and itemTABLE_item= '$actitmn' ");
$query1->execute();
$query1= $dbh -> prepare("UPDATE requestitem set requestitem_approvedNo = '$actiapprvno' WHERE requestitem_id=:stffid LIMIT 1");
$query1-> bindParam(':stffid', $actid, PDO::PARAM_STR);
$query1->execute();
header("location: cluster-request-made.php?deptcluster=$actclust");
}
}
------------表查询
<div class="panel panel-default">
<div class="panel-heading">Listed Items</div>
<div class="panel-body">
<form method="post" class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="">
<?php if($error??''){?>'
<div class="errorWrap"><strong>ERROR</strong>:<?php echo htmlentities($error); ?>
</div>
<?php }
else if($msg??''){?>
<div class="succWrap"><strong>SUCCESS</strong>:<?php echo htmlentities($msg); ?>
</div>
<?php }?>
<div style="overflow-x:auto;">
<table id="zctb" class="display table table-striped table-bordered table-hover" cellspacing="0" width="100%">
<thead>
<tr>
<th>SERIAL #</th>
<th>DEPARTMENT</th>
<th>NAME</th>
<th>TOTAL</th>
<th style="width:150px">Change Quantity: </th>
<th>REQUESTOR</th>
<th>DATE REQUESTED</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php $sql = "SELECT * from requestitem WHERE requestitem_cluster = '$deptclstr' AND requestitem_collectdate = 'Not Yet' AND requestitem_Hclusterapprv = 2 and ( (requestitem_Haccountapprv = '0' and requestitem_FAapprv = '0') or (requestitem_Haccountapprv = '1' and requestitem_FAapprv = '0') or (requestitem_Haccountapprv = '2' and requestitem_FAapprv = '1') or (requestitem_Haccountapprv = '3')) ORDER BY requestitem_Haccountapprv, (requestitem_FAapprv) ASC" ;
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{
$rqusthCLHDAPPRV = ($result->requestitem_Hclusterapprv);
$rqustID = ($result->requestitem_id);
$rqustNo = ($result->requestitem_approvedNo);
$rqustITM = ($result->requestitem_item);
$rqustCLST = ($result->requestitem_cluster);
$rqustNUMB = ($result->request_deptcartitm_NUMBER);
//$rqustQUNTY = array($_POST['NewQunty']);
?>
<tr>
<td style="font-size:15px"><?php echo htmlentities($result->request_NUMBER);?></td>
<td style="font-size:15px"><?php echo htmlentities($result->requestitem_department);?></td>
<td style="font-size:15px"><?php echo htmlentities($result->requestitem_item);?></td>
<?php if ($rqustNo ==0 || (empty($rqustNo))) { ?>
<td style="width:15px"><?php echo htmlentities($result->requestitem_no);?> </td>
<?php } else { ?>
<td style="width:15px"><?php echo htmlentities($result->requestitem_approvedNo);?> </td>
<?php } ?>
<td style="font-size:15px">
<input type="checkbox" id="myCheck" name="NewQuanty" /> Yes / No
<div class="row" id="area" style="display: none;" >
<div style = "position:relative; left:15px; top:2px;">
<input style="display:none;" style="font-size:15px" type="text" name="rqustID[]" value="<?php echo htmlentities($result->requestitem_id);?>" readonly >
<input type="text" class="form-control" name="NewQunty[]" data-toggle="dropdown" id="reply" aria-haspopup="true" aria-expanded="false" aria-describedby="basic-addon2" placeholder="New Quantity"> |
<button style="font-size:15px" class="btn btn-sm btn-info" type="submit" class="glyphicon glyphicon-floppy-save"><span class="glyphicon glyphicon-floppy-save"></span> Update</button>
</div></div>
</td>
<td style="font-size:15px"><?php echo htmlentities($result->requestitem_requestor);?></td>
<td style="font-size:15px"><?php echo htmlentities($result->date_created);?></td>
<?php
$dates = (date("Y-m-d H:i:s"));
$requestitemN0 = $result->request_NUMBER;
$query1= $dbh -> prepare("SELECT distinct * FROM requestitem WHERE request_NUMBER='$requestitemN0' ORDER BY request_NUMBER");
$query1->execute();
while ($row = $query1->fetch()){
$requestNUMB = $row['request_NUMBER']?? '';
}?>
<td style="font-size:15px">
<?PHP if(($result->requestitem_Haccountapprv)==0) {
echo '<a style="font-size:20px" href="script/update_status_clustarequest.php?id='.$result->requestitem_id.'&itemnam='.$result->requestitem_item.'&requstitemapprvdNo='.$result->requestitem_approvedNo.'&requstitemcluster='.$result->requestitem_cluster.'&itemnumb='.$result->request_deptcartitm_NUMBER.'&activation=1" class="btn btn-sm btn-info">Confirm</a>';
// echo ' <a style="font-size:20px" href="script/update_status_clustarequest.php?id='.$result->requestitem_id.'&itemnam='.$result->requestitem_item.'&requstitemapprvdNo='.$result->requestitem_approvedNo.'&itemnumb='.$result->request_deptcartitm_NUMBER.'&activation=2" class="btn btn-sm btn-primary">Forward to F & A</a>'; ?>
| <input type="hidden" id="rjctrsn-data" href="" name="rejection_reason"> <a type="submit" name="rejectreason" onclick="showRejectionReasonAlert()" class="btn btn-xs delete-record" data-id="0"><span style="font-size:25px" class="glyphicon glyphicon-remove text-danger" style="color:red"></span></a> <?php
}else if ($rqusthCLHDAPPRV == 1) {
echo '<p><a style="font-size:20px" class="btn btn-sm btn-success">Confirmed</a></p>';
答: 暂无答案
评论
<form