我是PHP和SQL的初學者。我一直在嘗試使用下面的代碼刪除SQL表中的行,但它不起作用。請幫忙。使用PHP刪除SQL記錄
<?php
/*
DELETE.PHP
Deletes a specific entry from the 'db' table
*/
// connect to the database
include('connect-db.php');
// check if the 'id' variable is set in URL, and check that it is valid
// get id value
$id = $_GET['id'];
// delete the entry
$result = mysql_query("DELETE FROM db WHERE 'Report No.'= '$id'")
or die(mysql_error());
// redirect back to the view page
header("Location: view.php");
// if id isn't set, or isn't valid, redirect back to view page
{
header("Location: view.php");
}
?>
db是你的表名嗎?和報告編號?這是什麼,在這裏你需要給你的表字段名稱。 –
使用引號列表名替換使用反引號 – Saty
回顯刪除查詢並在phpmyadmin SQL選項卡上運行。它執行了嗎? –