我有从数据库中删除数据的问题,我做了一个表,它将显示注册用户的名称和密码。并在他们旁边有一个删除链接。 当我按下删除链接,它给了我一个错误。从数据库中删除数据在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