在下图中,单击第三列中的“ 提交”按钮后,我要将跟踪ID从表2的列复制到表1的列。...
表订单
第4列中显示的跟踪ID”
我将订单信息保存在表 orders [Table 1]
中我在表 awbno [表2]和 tracking_two
列中保存了跟踪IDtrack.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['tracking_one'])) {
echo "<form method='post' action='call.php'>";
echo "<input type ='hidden' name='id' value='$id'>
<input type='submit'>
</form>";
}
echo "</td>";
echo "<td>" . $row['tracking_one'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
call.php
<?php
$con = mysqli_connect("localhost","root","","do_management4");
$result = mysqli_query($con,"SELECT * FROM orders");
$id = $_POST['id'];
$r = "";
$sql = $con->query("update orders set tracking_one = '$r' WHERE id ='$id'");
mysqli_close($con);
?>
我没有在Google中找到任何特定的查询,什么查询对我有帮助?
答案 0 :(得分:1)
您的查询应该是这样的
$sql = $con->query("update orders set tracking_one = (select tracking_two from awbno WHERE id =$id)");