<?php
require_once("connection to server.php");
?>
<link rel="stylesheet" type="text/css" media="all" href="niceforms-default.css"">
<table>
<?php
error_reporting (0);
mysql_select_db("leave_db");
$mysql="SELECT * FROM users WHERE Username='$_POST[nameEdit]'";
$result=mysql_query($mysql);
while($row=mysql_fetch_array($result)){
?>
<thead>
<tr>
<table width="100%" id="rounded-corner" summary="2007 Major IT Companies' Profit">
<tbody>
<td></td>
<td width="40%"><?php echo $row['Fname'];?> <?php echo $row['Lname'];?></td>
<td width="10%"><?php echo $row['Sex'];?></td>
<td width="20%"><?php echo $row['Nationality'];?></td>
<td width="20%"><?php echo $row['Role'];?></td>
<td width="10%"><a href="delete_user.php?id=".$row[0] class="ask"><img src="images/trash.png" alt="" title="" border="0" /></a></td>
</tbody>
</table>
<?php
}
?>
<?php
mysql_close();
?>
<?php
require_once "config.php";
if (isset($_GET['id'])){
$id = $_GET['id'];
$del=mysql_query("DELETE FROM users WHERE UserID ='$id'");
if($del){
echo "<p><span style='font-weight:bold; color:#0000FF; margin-left:150px;'>Successfully deleted</span></p>"; header("Location:delete_user.php");
}
else
echo "<p><span style='font-weight:bold; color:#FF0000; margin-left:150px;'>An Error while deleting ".mysql_error()."</span></p>";
}
?>
</table>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
这是我的代码,我想从我的数据库中删除数据,它运行得很好,但不删除数据,因为我想选择从数据库中检索到的值
像 名称用户名 伊恩i234
所以,如果选择使用i234删除它,则不会删除
答案 0 :(得分:0)
您尚未包含delete_user.php的代码。
我也猜测以下行是错误的: -
<td width="10%"><a href="delete_user.php?id=".$row[0] class="ask"><img src="images/trash.png" alt="" title="" border="0" /></a></td>
你不能只是将HTML粘贴在html中并期望它能够正常工作。
您需要将其更改为以下内容。
<td width="10%"><a href="delete_user.php?id=<?=$row[0];?>" class="ask"><img src="images/trash.png" alt="" title="" border="0" /></a></td>