简体   繁体   中英

Data is not being stored in the database

My code is getting the ID from another, after I get that ID I will insert it to another table. The thing is it's not working, any idea why?

<?php 

session_start(); 
include("Connection.php");
    if (isset($_POST['submit'])){  
    $name = $_POST['customerName'];
    mysql_query("INSERT INTO  `starbucks`.`orders` (
`ID` ,
`NAME` ,
`TOTAL_PRICE` ,
`TOTAL_ITEMS` ,
`TIME`
)
VALUES (
'' ,  '$name',  '', '',NOW())");

$_SESSION['user'] = $name; 
}
$dTime = time();
$myValue = isset($_REQUEST['dValue']) ?$_REQUEST['dValue'] : '';
echo "The time is: {$dTime}<br/>
The choice is {$myValue} ";

$sql = "Select * from product where NAME = '{$myValue}'";
 $result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
    $price = $row['PRICE'];
    $id = $row['ID'];
    echo $id;
    $sql2 ="INSERT INTO starbucks`.order_details (ID, ORDER_ID, PRODUCT_ID, QTY) VALUES ('', '', '$id', '1')";
   $result2 = mysql_query($sql2);
}
?>

INSERT中的额外后退标记,添加另一个或删除

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM