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
彼はそれによって何を意味し、どのようにそれを解決できますか! 午前