我正在尝试解决从 mysql 删除记录的问题,请参阅代码
<?php
$dbcs = new mysqli("localhost", "root", "password", "database-name");
// Check connection
if (mysqli_connect_errno($dbcs))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$product_list = "";
$sql = "SELECT * FROM product ORDER BY product_id DESC";
$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"];
$product_detail = $row["product_detail"];
$product_image = $row["screenshot"];
$screenshot = $row["screenshot"];
$product_list .= '<table width="80%" border="1">
<tr>
<td width="172" valign="top"> echo <img src="' . GW_UPLOADPATH . $screenshot .'" width="111" height="149" alt="<?php echo $product_name; ?>" /><br /><a href="../product_images/<?php echo $product_id; ?>.jpg">View Full Size Image</a></td>
<td width="85" class="product-text">' . $product_id . '</td>
<td width="402" class="product-text">' . $product_name . '</td>
<td width="108" align="center" class="product-text">' . $product_price . '</td>
<td width="34" align="center" class="product-text"><a href="edit_product.php?pid=' . $product_id . '">Edit</a></td>
<td width="56" align="center" class="product-text"><a href="product.php?deleteid=' . $product_id . '">Delete </a></td>
<td width="56" align="center" class="product-text"><a href="view_product.php?pid=' . $product_id . '">View</a></td>
</tr>
</table> ';
}
if (empty($product_list)) {
$product_list = "You have no product listed in your data yet";
}
mysqli_close($dbcs);
?>
然后这是用于 php 删除代码
<?php
///////////////////////////////////////////////////////////////////////////
// Delete Item Question to Admin, and Delete Product if they choose
///////////////////////////////////////////////////////////////////////////
if (isset($_GET['deleteid'])) {
echo 'Do you really want to delete product with ID of ' . $_GET['deleteid'] . '? <a href="product.php?yesdelete=' . $_GET['deleteid'] . '">Yes</a> | <a href="product.php">No</a>';
exit();
}
if (isset($_GET['yesdelete'])) {
//////////////////////////////////////////////////////////
// remove item from system and delete its picture
// delete from database
//////////////////////////////////////////////////////////
$id_to_delete = $_GET['yesdelete'];
$sql ("DELETE FROM product WHERE product_id='$id_to_delete' LIMIT 1") or die (mysql_error());
/////////////////////////////////////////////////////////////
// unlink the image from server
// Remove The Pic -------------------------------------------
/////////////////////////////////////////////////////////////
$pictodelete = ("../product_images/$id_to_delete.jpg");
if (file_exists($pictodelete)) {
unlink($pictodelete);
}
header("location: product.php");
exit();
}
?>
当我运行它以选择项目并按删除并按是删除时,我收到错误消息
Fatal error: Call to undefined function SELECT * FROM product ORDER BY product_id DESC() in C:\VertrigoServ\www\shopone\admin\data\product.php on line 131
他的意思是什么,怎么能解决这个问题!是