PHP 개발 학생 관리 튜토리얼 수정

edit.php를 생성하고


함수 처리 과정은 다음과 같습니다

8.jpg

코드는 다음과 같습니다

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生管理系统</title>
</head>
<body>
    <?php include ('menu.php');
 //1. 链接数据库
 header("content-type:text/html;charset=utf8");
 $conn=mysqli_connect("localhost","root","root","study");
    mysqli_set_charset($conn,"utf8");
$id=$_GET['id'];
 //2.执行sql
 $sql_select = "select * from stu where id='$id'";
 $stmt = mysqli_query($conn,$sql_select);
//    var_dump($stmt);
//    die();
 $stu = mysqli_fetch_assoc($stmt); // 解析数据
 ?>
 <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><input type="text" name="class" value="<?php echo $stu['class']?>"></td>
            </tr>
            <tr>
                <td> </td>
                <td><input type="submit" value="修改"></td>
                <td><input type="reset" value="重置"></td>
            </tr>
        </table>
    </form>
<?php
?>
</body>
</html>



지속적인 학습
||
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>学生管理系统</title> </head> <body> <?php include ('menu.php'); //1. 链接数据库 header("content-type:text/html;charset=utf8"); $conn=mysqli_connect("localhost","root","root","study"); mysqli_set_charset($conn,"utf8"); $id=$_GET['id']; //2.执行sql $sql_select = "select * from stu where id='$id'"; $stmt = mysqli_query($conn,$sql_select); // var_dump($stmt); // die(); if ($stmt>0) { $stu = mysqli_fetch_assoc($stmt); // 解析数据 }else{ die("no have this 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><input type="text" name="class" value="<?php echo $stu['class']?>"></td> </tr> <tr> <td> </td> <td><input type="submit" value="修改"></td> <td><input type="reset" value="重置"></td> </tr> </table> </form> <?php ?> </body> </html>
  • 코스 추천
  • 코스웨어 다운로드
현재 코스웨어를 다운로드할 수 없습니다. 현재 직원들이 정리하고 있습니다. 앞으로도 본 강좌에 많은 관심 부탁드립니다~