亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從數據庫中捕獲 ID 以更新狀態?

如何從數據庫中捕獲 ID 以更新狀態?

PHP
肥皂起泡泡 2021-10-15 10:37:51
我正在嘗試通過單擊更新按鈕將狀態從待處理更新為“已批準”。但是,當我單擊按鈕時,它沒有響應并更改狀態。但是,如果我對 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 關注
  • 190 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號