在track.php页面中,一旦我们单击“ 提交”按钮[第一行],我想更新“ ecomexpress_awb ”表-> orderid 列”,其值为 123456789 ....
Track.php 页面[基于 Orders 表]:
下面是表订单:
下面是表 ecomexpress_awb
Track.php
<?php
$con = mysqli_connect("localhost","root","","do_management4");
$result = mysqli_query($con,"SELECT * FROM orders");
echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";
echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Call.php
<?php
$con = mysqli_connect("localhost","root","","do_management4");
$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");
$awb_id='';
$awb_id = $_POST['awb_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '' WHERE awb_id ='$awb_id'");
mysqli_close($con);
?>
答案 0 :(得分:1)
检查此代码,这可能对您有帮助 如果您有abb,则在订单表中插入记录时应插入abb,然后可以像这样
更新Track.php
<?php
$con = mysqli_connect("localhost","root","","do_management4");
$result = mysqli_query($con,"SELECT * FROM orders");
echo "<table border='1'>
<tr>
<th>order</th>
<th>payment</th>
<th>generate</th>
<th>tracking id</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo "<tr>";
echo "<td>" . $row['order_id'] . "</td>";
echo "<td>" . $row['payment_type'] . "</td>";
echo "<td>";
if (empty($row['awb'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['awb'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Call.php
<?php
$con = mysqli_connect("localhost","root","","do_management4");
$result = mysqli_query($con,"SELECT * FROM ecomexpress_awb");
$awb_id='';
$awb_id = $_POST['awb_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb_id ='$awb_id'");
mysqli_close($con);
//Added code
$order_id='';
if(isset($_POST['order_id']) && $_POST['order_id']!=''){
$order_id = $_POST['order_id'];
$awb= $_POST['awb'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}
//End added code
?>
答案 1 :(得分:1)
在Track.php的按钮表单中添加一个字段:
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type ='hidden' name='order_id' value='".$row['order_id']."'>
<input type ='hidden' name='awb' value='".$row['awb']."'>
<input type='submit'>
</form>";
,然后在call.php中更新更新查询:
if(isset($_POST['order_id'], $_POST['awb'])
&& !empty($_POST['order_id'])
&& !empty($_POST['awb'])){
$con = mysqli_connect("localhost","root","","do_management4");
$awb = $_POST['awb'];
$order_id = $_POST['order_id'];
$sql = $con->query("update ecomexpress_awb set orderid = '".$order_id."' WHERE awb ='".$awb."'");
mysqli_close($con);
}