这是结帐代码。我的查询值无法正常运行。它不插入请帮我解决这个问题。
$q = "select * from cart";
$quer = mysqli_query($con, $q);
while($q_row = mysqli_fetch_array($quer)){
$order_id = $q_row['order_id'];
$prod_id = $q_row['p_id'];
//get p_id
$p_id_q = "select * from products where prod_id = '$prod_id'";
$run_products = mysqli_query($con, $p_id_q);
$row_product = mysqli_fetch_array($run_products);
$product_id = $row_product['prod_id'];
$product_name = $row_product['prod_name'];
$add_order = "insert into orders (order_id,p_id,prod_name,status) values ('$order_id','$prod_id','$prod_name','Pending')";
$run_add = mysqli_query($con, $add_order);
}
}
?>
答案 0 :(得分:0)
您已声明$ product_name但在插入查询中使用$ prod_name