我正在尝试从编辑页面将产品信息更新到 mysql 数据库中,但我显示它没有做任何事情,甚至没有显示任何错误。
我错过了什么?
<?php
$dbcs = new mysqli("localhost", "root", "password", "shopping");
// Check connection
if (mysqli_connect_errno($dbcs))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Parse the form data and update company information to the system
if (isset($_POST['product_name'])) {
$pid = $_POST['thisID'];
$product_name = $_POST['product_name'];
$product_category = $_POST['product_category'];
$product_product_retail_price = $_POST['product_retail_price'];
$product_price = $_POST['product_price'];
// See if that company name is an identical match to another company in the system
$sql = "UPDATE product SET
product_name='$product_name',
product_category='$product_category',
product_retail_price='$product_retail_price',
product_price='$product_price'
WHERE product_id='$pid'" or die(mysql_error());
header("location: product.php");
exit();
}
// Gather these companies full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
$targetID = $_GET['pid'];
$sql = "SELECT * FROM product WHERE product_id='$targetID' LIMIT 1";
$result=mysqli_query($dbcs,$sql);
while($row = mysqli_fetch_array($result)){
$product_id = $row["product_id"];
$product_name = $row["product_name"];
$product_category = $row["product_category"];
$product_retail_price = $row["product_retail_price"];
$product_price = $row["product_price"];
$screenshot =$row["screenshot"];
}
}
mysqli_close($dbcs);
?>