我有從數據庫中刪除數據的問題,我做了一個表,它將顯示註冊用戶的名稱和密碼。並在他們旁邊有一個刪除鏈接。 當我按下刪除鏈接,它給了我一個錯誤。從數據庫中刪除數據在php中
這裏是viewTheUsers.php頁
<html>
<head>
<title>the users</title>
</head>
<body>
<table width ="650" align ="center" border ="2" >
<tr>
<th width="60">User No </th>
<th>User Name </th>
<th>User Password </th>
<th>Delete User </th>
</tr>
<?php
mysql_connect("hostName","userName","password");
mysql_select_db("db_name");
$Thequery = "SELECT * FROM table_name";
$run = mysql_query($Thequery);
while($row = mysql_fetch_array($run)){
$The_id = $row[0];
$The_name = $row[1];
$The_pass = $row[2];
?>
<tr>
<td><?php echo $The_id; ?></td>
<td><?php echo $The_name; ?></td>
<td><?php echo $The_pass; ?></td>
<td><a href="delete.php?deleting=<?php echo $The_id; ?>">Delete</a></td>
</tr>
<?php }?>
</table>
</body>
</html>
這裏是delete.php頁:
<?php
mysql_connect("hostName","userName","password");
mysql_select_db("db_name");
$deleting_id = $_GET['deleting'];
$Thequery = "delete from users where id = '$deleting_id' ";
if (mysql_query($Thequery)){
echo "<script>window.open('viewTheUsers.php?deleted = user has been deleted!!!','_self')</script>";
}
?>
的massege錯誤說:
公告:未定義索引:在C:\ wamp \ www \ delete中刪除.php on line 6
你知道mysql。*函數被折舊嗎? – imulsion
delete.php的第6行是什麼? – Barmar
這個錯誤表明你有'$ _GET ['del']'在你的腳本代替'$ _GET ['刪除']'檢查輸入錯誤 – Barmar