国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP development student management system to modify student information

Create edit.php and modify the file

Read the information in the database in the specified format and make corresponding modifications (using HTML and PHP), and then store the new data in the database

5.jpg

The code is as follows


edit.php file code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>學(xué)生管理系統(tǒng)</title>
</head>
<body>
    <?php include ('menu.php');
 //1. 鏈接數(shù)據(jù)庫
 header("content-type:text/html;charset=utf8");
 $conn=mysqli_connect("localhost","root","root","study");
    mysqli_set_charset($conn,"utf8");
$id=$_GET['id'];
 //2.執(zhí)行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); // 解析數(shù)據(jù)
 }else{
 die("no have this id:{$_GET['id']}");
    }
 ?>
 <h3>修改學(xué)生信息</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>班級(jí)</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>
</body>
</html>

Resubmit the modified data on the modified page to the database

1.jpg

The code is as follows

<?php
header("content-type:text/html;charset=utf8");
$conn=mysqli_connect("localhost","root","root","study");
mysqli_set_charset($conn,"utf8");
            $id = $_POST['id'];
            $name = $_POST['name'];
            $age = $_POST['age'];
            $class = $_POST['class'];
            $sex = $_POST['sex'];
            $sql = "update stu set name='$name', age='$age',sex='$sex',class='$class' where id='$id';";
            $rw = mysqli_query($conn,$sql);
            if ($rw > 0){
                echo "<script>alert('修改成功');</script>";
            }else{
                echo "<script>alert('修改失敗');</script>";
            }
            header('Location: index.php');
?>

This completes our modification function. The next step is our delete function



Continuing Learning
||
<body> <meta charset="UTF-8"> <title>登陸界面</title> <h2>學(xué)生管理系統(tǒng)</h2> <a href="index.php"> 瀏覽學(xué)生</a> <a href="add.php"> 添加學(xué)生</a> <hr> <h3>修改學(xué)生信息</h3> <form action="action.php?action=edit" method="post"> <input name="id" value="3" type="hidden"> <table> <tbody><tr> <td>姓名</td> <td><input name="name" value="劉奇" type="text"></td> </tr> <tr> <td>年齡</td> <td><input name="age" value="12" type="text"></td> </tr> <tr> <td>性別</td> <td> <input name="sex" value="男" checked="" type="radio">男 </td> <td> <input name="sex" value="女" type="radio">女 </td> </tr> <tr> <td>班級(jí)</td> <td><input name="class" value="五年級(jí)" type="text"></td> </tr> <tr> <td> </td> <td><input value="修改" type="submit"></td> <td><input value="重置" type="reset"></td> </tr> </tbody></table> </form> </body>
submitReset Code