所以几个小时以来我一直在努力解决这个问题。任何帮助将不胜感激 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 Connection
if(!empty($_POST))
{
$output = '';
$message = '';
$ostatus = mysqli_real_escape_string($connect, $_POST["ostatus"]);
if($_POST["order_oid"] != '')
{
$query = "
UPDATE orders
SET 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 调用插入页面。帮助将不胜感激 谢谢。
江户川乱折腾
相关分类