<?php
//连接数据库
$link_id = mysql_connect("localhost","root","") or die("连接失败");
if($link_id)
{
mysql_select_db("my_test");
if(!$_GET[id])
{
$result=mysql_query("select * from userinfo");
echo "<TABLE border=1>
<TR>
<TD>编号</TD>
<TD>用户名称</TD>
<TD>性别</TD>
<TD>年龄</TD>
<TD>注册时间</TD>
<TD>操作</TD>
</TR>";
while($row=mysql_fetch_array($result)){
echo "<TR>
<TD>".$row[id]."</TD>
<TD>".$row[username]."</TD>
<TD>".$row[gender]."</TD>
<TD>".$row[age]."</TD>
<TD>".$row[regdate]."</TD>
<TD><a href=delete.php?id=".$row[id].">删除</a></TD>
</TR>";
}
echo "</TABLE>";
}//显示列表的内容
else
{
$sql="delete from userinfo where id=".$_GET[id];
$result=mysql_query($sql);
if($result)
echo "记录已经成功删除<br><a href='delete.php'>返回</a>";
else
echo "记录删除失败<br><a href=delete.php.php?id=".$_GET[id].">返回</a>";
}//else($id部分)
} // end if
?>