我正在嘗試通過單擊更新按鈕將狀態從待處理更新為“已批準”。但是,當我單擊按鈕時,它沒有響應并更改狀態。但是,如果我對 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 回答
- 0 關注
- 190 瀏覽
添加回答
舉報
0/150
提交
取消