所以幾個(gè)小時(shí)以來我一直在努力解決這個(gè)問題。任何幫助將不勝感激 Homepage- index.php連接器.php<?php$connect = mysqli_connect("localhost", "dummy", "123456", "www") or die ('I cannot connect to the database because: ' . mysql_error())?>插入.php<?php include 'conn.php'; // MySQL Connectionif(!empty($_POST)) { $output = ''; $message = ''; $ostatus = mysqli_real_escape_string($connect, $_POST["ostatus"]); if($_POST["order_oid"] != '') { $query = " UPDATE ordersSET ostatus='$ostatus', WHERE oid='".$_POST["order_oid"]."'"; $message = 'Data Updated'; } else { $query = " INSERT INTO orders(ostatus) VALUES('$ostatus'); "; $message = 'Added Record Successfully'; } if(mysqli_query($connect, $query)) { $output .= '<label class="text-success">' . $message . '</label>'; $select_query = "SELECT * FROM orders ORDER BY id DESC"; $result = mysqli_query($connect, $select_query); $output .= ' <table class="table table-bordered"> <tr> <th width="70%">Customer Name</th><th width="70%">Customer Address</th><th width="70%">Customer Mobile</th><th width="70%">Payment Method</th><th width="70%">Order Status</th><th width="15%">Edit</th> <th width="15%">View</th> </tr> '; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td><?php echo $row["oname"]; ?></td> <td><?php echo $row["odeladd"]; ?></td><td><?php echo $row["omobile"]; ?></td><td><?php echo $row["opaymethod"]; ?></td><td><?php echo $row["ostatus"]; ?></td><td><input type="button" name="edit" value="Edit" id="'.$row["oid"] .'" class="btn btn-info btn-xs edit_data" /></td> <td><input type="button" name="view" value="view" id="' . $row["id"] . '" class="btn btn-info btn-xs view_data" /></td> </tr> '; } $output .= '</table>'; } echo $output; } ?>有兩個(gè)名為 orders 和 ordersdata 的表,它們都有 oid 作為公共列。兩者都在同一個(gè)數(shù)據(jù)庫(kù)中,稱為 www。當(dāng)我點(diǎn)擊編輯按鈕時(shí),應(yīng)該會(huì)顯示 ajax 彈出窗口,但事實(shí)并非如此?,F(xiàn)在我從編輯中獲取 oid,從視圖中獲取 id。為我已通過 order_oid 的 edit_data 調(diào)用插入頁(yè)面,為我已通過 order_id 的 view_data 調(diào)用插入頁(yè)面。幫助將不勝感激 謝謝。
使用帶有 sql 的 php 的 Ajax 彈出視圖更新數(shù)據(jù)
牧羊人nacy
2022-12-23 15:16:15