データベースにデータを挿入しようとしています。エラーはありませんが、データベースはまだ更新されていません。データベースのproduct
テーブルには、productid、categoryid、productname、productimage、stock、price が含まれており、detailsales
テーブルには transactionid、productid、および quantity が含まれています。
更新は機能していますが、挿入はまったく機能していません。
これが私のコードです:
<form action="doShop.php" method="post">
<table border="1">
<tr>
<td>Product ID</td>
<td>Product Name</td>
<td>Product Image</td>
<td>Price</td>
<td>Product Stock</td>
<td> Quantity</td>
</tr>
<?php
$query = mysql_query("SELECT * FROM Product");
while($row = mysql_fetch_array($query)){
?>
<tr>
<td><input type="text" value="<?=$row['ProductID']?>" name="productid"></td>
<td><?=$row['ProductName']?></td>
<td><img src="image/<?=$row['ProductImage']?>"></td>
<td><?=$row['Price']?></td>
<td><input type="text" value="<?=$row['Stock']?>" name="stock"></td>
<td><input type="text" name="quantity"></td>
</tr>
<?php
}
print mysql_error();
?>
</table>
<table>
<tr><input type="submit" value="Submit"></tr>
</table>
</form>
doShop コードは次のとおりです。
<?php
include("connect.php");
$id=$_REQUEST['productid'];
$quantity=$_REQUEST['quantity'];
$stock = $_REQUEST['stock'];
mysql_query("insert into DetailSales(ProductID, Quantity)values('".$id."','".$quantity."')");
mysql_query("update product set stock = $stock - $quantity where detailsales.productid = product.productid");
header("location:shopcart.php");
?>
誰でも私を助けることができますか?