所以几个小时以来我一直在努力解决这个问题。任何帮助将不胜感激 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 弹出窗口,但事实并非如此。现在我从编辑中获取 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");
添加回答
举报
0/150
提交
取消