copy the tracking id from Table 2’s column to Table 1’s column Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of copy the tracking id from Table 2’s column to Table 1’s column without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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….

Table orders

enter image description here

displayed tracking id” in 4th column

enter image description here

I saved order information in table orders [ Table 1 ]

enter image description here

I saved tracking ids in table awbno [ Table 2 ] & in column tracking_two

enter image description here

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

<?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 ?

Answer

Your query should be something like this

$sql = $con->query("update orders set tracking_one = (select tracking_two from awbno WHERE id =$id)");
We are here to answer your question about copy the tracking id from Table 2’s column to Table 1’s column - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji