我想显示已添加的结算单位,仅针对特定用户(由其ID确定)。可能吗?
<?php
$query3 = "SELECT * FROM account WHERE user_id = '$user_id' AND account_id = '$account_id'";
$result3 = mysqli_query($link, $query3) or die(mysqli_error($link));
$row2 = mysqli_fetch_array($result1);
$user_id = $_SESSION['user_id'];
$billing_name_id = $_POST['billing_name_id'];
$billing_reference_num = $_POST['billing_reference_num'];
$transaction_amount = $_POST['transaction_amount'];
$account_number = $_POST['account_number'];
$account_id = $_POST['account_id'];
$query4 = "INSERT INTO billinghistory (billing_name_id, billing_reference_num, transaction_amount, account_id)
VALUES('$billing_name_id','$billing_reference_num', '$transaction_amount','$account_id')";
$result4 = mysqli_query($link, $query4) or die(mysqli_error($link));
?>
谢谢!
答案 0 :(得分:0)
你可以尝试这个..你必须首先获得$ user_id然后执行所选用户的查询。
<?php
$user_id = $_SESSION['user_id'];
$account_id = $_POST['account_id'];
$query3 = "SELECT * FROM account WHERE user_id = '$user_id' AND account_id = '$account_id'";
$result3 = mysqli_query($link, $query3) or die(mysqli_error($link));
$row2 = mysqli_fetch_array($result1);
$billing_name_id = $_POST['billing_name_id'];
$billing_reference_num = $_POST['billing_reference_num'];
$transaction_amount = $_POST['transaction_amount'];
$account_number = $_POST['account_number'];
$query4 = "INSERT INTO billinghistory (billing_name_id, billing_reference_num, transaction_amount, account_id)
VALUES('$billing_name_id','$billing_reference_num', '$transaction_amount','$account_id')";
$result4 = mysqli_query($link, $query4) or die(mysqli_error($link));
?>