<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>学生管理系统</title>
</head>
<body>
<?php include ('menu.php');
//链接数据库
header("content-type:text/html;charset=utf8");
$conn=mysqli_connect("localhost","root","root","edu");
mysqli_set_charset($conn,"utf8");
$id=$_GET['id'];
//执行sql
$sql_select = "select * from stu where id='id'";
$stmt = mysqli_query($conn,$sql_select);
//判断
if ($stmt > 0)
{
$stu = mysqli_fetch_assoc($stmt); // 解析数据
}else{
die("没有这个id:{$_GET['id']}");
}
?>
<h3>修改学生信息</h3>
<form action="action.php?action=edit" method="post">
<input type="hidden" name="id" value="<?php echo $stu['id'];?>">
<table>
<tr>
<td>姓名</td>
<td><input type="text" name="name" value="<?php echo $stu['name'];?>"></td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" name="age" value="<?php echo $stu['age'];?>"></td>
</tr>
<tr>
<td>性别</td>
<td>
<input type="radio" name="sex" value="男" <?php echo ($stu['sex'] == "男")? "checked":"";?> >男
</td>
<td>
<input type="radio" name="sex" value="女" <?php echo ($stu['sex'] == "女")? "checked":"";?> >女
</td>
</tr>
<tr>
<td>宝宝</td>
<td> </tr>
<tr>
sunten2019-02-13 21:25:57
遇到同样问题,能修改成功就是提示:
Notice: Object of class mysqli_result could not be converted to int in E:\phpStudy\WWW\stu\edit.php on line 19