从一个表输出结果以更新另一个表

时间:2018-03-24 17:34:04

标签: php mysqli sql-update

如何输出t2来更新t3?

<?php
session_start();
require_once("../../../connection.php");

$sql = mysqli_query(
    $query, 
    "SELECT
        * 
    FROM
        `orders`
    INNER JOIN
        `order_track` ON `orders`.`order_id` = `order_track`.`order_id`
    WHERE
        `order_track`.`t2` = 'inactive'
    ORDER BY
        `orders`.`order_date` DESC"
);

if ($row = mysqli_fetch_row($sql)) {
    echo "
        <tr>
            <td>$row[0]</td>
            <td>$row[1]</td>
            <td>$row[2]</td>
            <td><button type='button' class='btn btn-success' onClick=\"approval('".$row[0]."')\">
                    Approve
                </button>
            </td>
        </tr>";
}?> 

<?php
session_start();
require_once("../../../connection.php");

$pid = $_REQUEST['pid'];

$sql = mysqli_query(
    $query, 
    "UPDATE
        `order_track`
     SET
         `t2` = 'active'
     WHERE
         `order_id` = '$pid'"
 );

if($sql){
    echo "success";
}?>

0 个答案:

没有答案