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

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

使用帶有 sql 的 php 的 Ajax 彈出視圖更新數據

使用帶有 sql 的 php 的 Ajax 彈出視圖更新數據

牧羊人nacy 2022-12-23 15:16:15
所以幾個小時以來我一直在努力解決這個問題。任何幫助將不勝感激 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;  }  ?>有兩個名為 orders 和 ordersdata 的表,它們都有 oid 作為公共列。兩者都在同一個數據庫中,稱為 www。當我點擊編輯按鈕時,應該會顯示 ajax 彈出窗口,但事實并非如此?,F在我從編輯中獲取 oid,從視圖中獲取 id。為我已通過 order_oid 的 edit_data 調用插入頁面,為我已通過 order_id 的 view_data 調用插入頁面。幫助將不勝感激 謝謝。
查看完整描述

1 回答

?
江戶川亂折騰

TA貢獻1851條經驗 獲得超5個贊

你應該打電話


$('#add_data_Modal').modal('show');


像這樣,


$(document).on('click', '.edit_data', function() {

var order_oid = $(this).attr("id");

$('#add_data_Modal').modal('show');


我認為, .attr("oid"); (var order_oid) 作為未定義傳遞,您應該將其更改為 .attr("id");


查看完整回答
反對 回復 2022-12-23
  • 1 回答
  • 0 關注
  • 101 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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