我正在尝试将一行从一个表移动到另一个表,但它不起作用。它的第一行很好,但没有什么我可以让其余的回声好,只是不要进入我的数据库。
$result = mysql_query("SELECT * FROM coffees WHERE id='$id'");
while($row = mysql_fetch_array($result)) {
mysql_query("INSERT INTO coffeeorder(coffeetype,topping,shots,milk,size,price) VALUES ('coffeetype', 'topping', 'shots', 'milk', 'Size', 'price')");
echo $row['coffeetype'] . " " . $row['topping']." " . $row['shots']." " . $row['milk']." " . $row['size']." $" . $row['price']."<br />";
$totalPrice = $totalPrice + $row['price'];
}
任何想法为什么这不起作用?
完整代码:
<?php
session_start();
if(isset($_SESSION["id"])){
$id = $_SESSION["id"];
$name = $_SESSION["name"];
}else {header('Location: index.php');}
include_once "dbcon.php";
$totalPrice = 0;
$result = mysql_query("SELECT * FROM coffees WHERE id='$id'");
while($row = mysql_fetch_array($result))
{
mysql_query("INSERT INTO `coffeeorder`(`coffeetype`,`topping`,`shots`,`milk`,`size`,`price`) VALUES ('".$row['coffeetype']."', '".$row['topping']."', '".$row['shots']."', '".$row['milk']."', '".$row['size']."', '".$row['price']."')");
echo $row['coffeetype'] . " " . $row['topping']." " . $row['shots']." " . $row['milk']." " . $row['size']." $" . $row['price']."<br />";
$totalPrice = $totalPrice + $row['price'];
}
echo "Total Price $".$totalPrice;
?>