我正在尝试通过单击更新按钮将状态从待处理更新为“已批准”。但是,当我单击按钮时,它没有响应并更改状态。但是,如果我对 ID 进行硬编码,则状态可以更新。如何从数据库中获取 ID 捕获并在单击按钮后更新状态?//edit1.php:<?php $con= mysqli_connect('127.0.0.1','root',''); if(!$con) { echo 'Not Connected To Server'; } if(!mysqli_select_db($con,'satsform1')) { echo 'Database Not Selected'; } $ID = 'ID'; $sql = "update handover set status= 'Approved' where ID = '$ID'"; if(!mysqli_query($con,$sql)) { echo 'Not Submitted'; } else { echo "<meta http-equiv='refresh' content='0;url=index3.php'>"; }?><?php//fetch3.php$connect = mysqli_connect('127.0.0.1','root','', 'satsform1');$output = '';if(isset($_POST["query"])){ $search = mysqli_real_escape_string($connect, $_POST["query"]); $query = " SELECT * FROM handover WHERE name LIKE '%".$search."%' OR staffno LIKE '%".$search."%' OR date LIKE '%".$search."%' OR email LIKE '%".$search."%' OR mobno LIKE '%".$search."%' OR roles LIKE '%".$search."%' OR location LIKE '%".$search."%' OR flightno LIKE '%".$search."%' OR flightdate LIKE '%".$search."%' OR seatno LIKE '%".$search."%' OR class LIKE '%".$search."%' ";}else{ $query = " SELECT * FROM handover ORDER BY ID ";}$result = mysqli_query($connect, $query);if(mysqli_num_rows($result) > 0){ $output .= ' <div class="table-responsive"> <table class="table table bordered"> <tr> <th>ID</th> <th>Staff Name</th> <th>Staff Number</th> <th> Status </th> </tr> '; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td>'.$row["ID"].'</td> <td>'.$row["name"].'</td> <td>'.$row["staffno"].'</td> <td>'.$row["status"].'</td> // this is the update button where use the edit1.php to update the status by ID <td> <form action="edit1.php" method="GET"> <button type="submit">update </button> </form> </td> </tr> '; } echo $output;}else{ echo 'Data Not Found';}?>我希望输出能够在单击更新按钮后将状态更新为“已批准”到数据库中。
1 回答
- 1 回答
- 0 关注
- 178 浏览
添加回答
举报
0/150
提交
取消