您的位置:首页 > 数据库

数据库删除操作2

2016-06-27 18:49 253 查看
/*deal_edit.php*/

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑处理</title>
</head>
<body>
<?php
include_once"connect.php";

$id=$_POST['id'];   //接受从编辑界面传过来的值。
$name=$_POST['name'];
$sex=$_POST['sex'];
$age=$_POST['age'];
if($_GET['ud'])
{
$ud=$_GET['ud'];
$sql="select * from stu where stu_id=$ud";//从数据库中选择将要编辑的学生信息。
$re=mysql_query($sql) or die(mysql_error());
if(!mysql_num_rows($re))
{
echo "ID wrong";
}
$row=mysql_fetch_array($re);
if(!empty($name)||trim($name)!='')  //判断姓名是否为空
{
$sql="update stu set stu_name='".$name."',stu_id='".$id."',stu_age='".$age."',stu_sex='".$sex."' where stu_id=$id";
mysql_query($sql) or die(mysql_error());
// echo "<center>";
// echo "Edit success!";
// echo '<a href="sy.php"><input name="return" type="button" value="return" ></a>';
// echo "</center>";
header('location:table.php');
mysql_close($conn);
}
}
else
{
echo "fail to delete!";
mysql_error();
}
?>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: