简体   繁体   English

将跟踪ID从表2的列复制到表1的列

[英]copy the tracking id from Table 2's column to Table 1's column

In below image , Once we click on " submit " button in third column , I want to copy the tracking id from Table 2's column to Table 1's column .... 在下图中,一旦单击第三列中的“ submit ”按钮,我想将跟踪ID从表2的列复制到表1的列 ...。

Table orders 订单

在此处输入图片说明

displayed tracking id" in 4th column 在第4列中显示的跟踪ID”

在此处输入图片说明

I saved order information in table orders [ Table 1 ] 我将订单信息保存在表订单中 [表1]

在此处输入图片说明

I saved tracking ids in table awbno [ Table 2 ] & in column tracking_two 我将跟踪ID保存在表awbno [表2]和列tracking_two中

在此处输入图片说明

track.php 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['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 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);

?>

I did't found any particular query in google, What query will help me ? 我在google中找不到任何特定的查询,什么查询对我有帮助?

您的查询应该是这样的

$sql = $con->query("update orders set tracking_one = (select tracking_two from awbno WHERE id =$id)");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM