deleteData.php 页面
<html>
<head>
</head>
<body>
<form name="frm" action="processDeleteData.php" method="post">
<table border="1" align="center" cellspacing="0" cellpadding="0">
<caption>学生一览表</caption>
<th>选项</th>
<th>学号</th>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th>地址</th>
<?php
$link=mysql_connect("localhost","root","root");
mysql_select_db("rorely");
$exec="select * from test";
$result=mysql_query($exec);
while($rs=mysql_fetch_object($result)){
$id=$rs->id;
$name=$rs->name;
$age=$rs->age;
$sex=$rs->sex;
$address=$rs->address;
?>
<tr align="center">
<td><input type="radio" name="del" value=<?php echo $id ?> /></td>
<td><?php echo $id ?></td>
<td><?php echo $name ?></td>
<td><?php echo $age ?></td>
<td><?php echo $sex ?></td>
<td><?php echo $address ?></td>
</tr>
<?php
}
mysql_close();
?>
</table>
<center><input type="submit" value="删除" /></center>
</form>
</body>
</html>
processDeleteData.php处理删除页面
<?php
$link=mysql_connect("localhost","root","root");
mysql_select_db("rorely");
$id=$_POST['del'];
$exec="delete from test where id=$id";
$result=mysql_query($exec);
if((mysql_affected_rows()==0)||(mysql_affected_rows()==-1))
echo"没有找到记录,或者删除时产生错误!";
else echo"学生已删除!";
mysql_close();
?>
<a href="deleteData.php">返回删除页面</a>
posted on 2009-07-01 15:30
期待明天 阅读(5611)
评论(5) 编辑 收藏 所属分类:
PHP