【发布时间】:2016-08-21 01:04:59
【问题描述】:
我希望下面的代码在customer_payment 表中插入汽车的ID,但它只选择477 作为ID。我不知道为什么。如下图所示,只插入了product_id = 477,没有插入任何其他值。如果我选择 500,它仍然会插入 477。
include 'admin/db.php';
if(isset($_GET['payment_here'])){
//select product id from cart
$select_cart = "select * from cart";
$runcart = mysqli_query($conn, $select_cart);
$cartwhile=mysqli_fetch_assoc($runcart);
$carssid = $cartwhile['P_ID'];
$cusid = $cartwhile['C_ID'];
//select id from cars
$scars = "select * from cars where id=$carssid";
$scarsrun = mysqli_query($conn, $scars);
$showcars = mysqli_fetch_assoc($scarsrun);
$carsdealer = $showcars['dealer'];
//select customer id from customer table
//$selectcust = "select * from customer_register where id=$cusid";
//insert data into customer payment table
echo $insertpay = "insert into customer_payment
(Product_id, customer_id, dealer)
values ( $carssid," . $_SESSION['customer_id'] . ", '$carsdealer')";
$run_inserts = mysqli_query($conn, $insertpay);
/*
if($run_inserts){
echo "<script>window.location.href = 'checkout.php'</script>";
}
*/
}
?>
为什么没有将正确的 ID 插入到该表中?
【问题讨论】: