I want to insert data from input form and at the same time from another table (shopping_cart) in one table (order).
I found that there is no problem with passing value from input form or select it from shopping cart, since I print all the value that I want to use to insert in table (order) and it displayed.
But, when execute a query to insert into table order, the output is fail and nothing insert in database.
Below is my code :
<?php
include('dbconnection.php');
$query1 = mysql_query("SELECT * FROM shopping_cart");
$bil = 1;
while ($data = mysql_fetch_array($query1)) {
//FROM TABLE SHOPPING_CART
$item_name=$data['ITEM_NAME'];
$cart_price=$data['CART_PRICE'];
$cart_quantity=$data['CART_QUANTITY'];
//FROM HTML FORM
$total_price = $_POST['ORDER_TOTALPRICE'];
$fullname = mysql_real_escape_string($_POST['FULLNAME']);
$address = mysql_real_escape_string($_POST['ADDRESS']);
$phone = mysql_real_escape_string($_POST['PHONE']);
echo $item_name;
echo $cart_price;
echo $cart_quantity;
echo $fullname;
echo $address;
echo $phone;
echo $total_price;
//SOMETHING WRONG HERE ?
$query = mysql_query("INSERT INTO order (ORDER_TOTALPRICE, ITEM_NAME,
CART_PRICE, CART_QUANTITY, FULLNAME, ADDRESS, PHONE) VALUES ('$total_price','$item_name','$cart_price','$cart_quantity','$fullname','$address','$phone')");
if ($query){
echo "success";
}
else{
echo "fail";
}
$bil++;
}
?>