<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> ;Student Management System</title>
</head>
<body>
<?php include ('menu.php');
//Link database
header("content-type:text/html;charset=utf8");
$conn=mysqli_connect("localhost","root","root","edu");
mysqli_set_charset($conn, "utf8");
$id=$_GET['id'];
//Execute sql
$sql_select = "select * from stu where id='id'";
$stmt = mysqli_query($conn,$sql_select);
//Judgment
if ($stmt > 0)
{
$stu = mysqli_fetch_assoc($stmt); // Parse data
}else{
die("No such id:{$_GET['id']}");
}
?>
<h3>Modify student information</h3>
<form action="action.php?action=edit" method="post">
<input type="hidden" name="id" value="<?php echo $stu ['id'];?>">
="text" name="name" value="<?php echo $stu['name'];?>"></td>
</tr>
;
?>"></td>
< ;input type="radio" name="sex" value="Male" <?php echo ($stu['sex'] == "Male")? "checked":"";?> >Male
= "female")? "checked":"";?> >female
</td>
</tr>
<tr>
<td>班级</td>
<td><input type="text" name="class" value="<?php echo $stu['class']?>"></td>
</tr>
<tr>
<td a href="index.php">返回</td>
<td><input type="submit" value="修改"></td>
<td><input type="reset" value="重置"></td>
</tr>
</table>
</form>
</body>
</html>
Encountered the same problem, if the modification is successful, the prompt is:
Notice: Object of class mysqli_result could not be converted to int in E:\phpStudy\WWW\stu\edit.php on line 19
You use post to send the value and use get to receive it. I guess it’s hard to receive it.
There is something wrong with the link database