PHP 개발 학생 관리 튜토리얼 찾아보기

index.php 파일 생성

코드 흐름은 아래와 같습니다

11.jpg

index.php 코드는 다음과 같습니다

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生信息管理</title>
    <script>
        function doDel(id) {
            if(confirm('确认删除?')) {
                window.location='action.php?action=del&id='+id;
            }
        }
    </script>
</head>
<body>
    <?php
    include ("menu.php");
 ?>
 <h3>浏览学生信息</h3>
    <table width="350" border="1" cellspacing="0">
        <tr>
            <th>ID</th>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
            <th>班级</th>
            <th>操作</th>
        </tr>
        <?php
 //    1. 链接数据库
 header("content-type:text/html;charset=utf8");
 $conn=mysqli_connect("localhost","root","root","study");
        mysqli_set_charset($conn,"utf8");
 //2.执行sql
 $sql_select = "select * from stu";
 //3.data 解析
 foreach ( $conn->query($sql_select) as $row) {
 echo "<tr>";
 echo "<th>{$row['id']} </th>";
 echo "<th>{$row['name']}</th>";
 echo "<th>{$row['sex']} </th>";
 echo "<th>{$row['age']} </th>";
 echo "<th>{$row['class']}</th>";
 echo "<td>
          <a href='edit.php?id={$row['id']}'>修改</a>
          <a href='javascript:void(0);' onclick='doDel({$row['id']})'>删除</a>
        </td>";
 echo "</tr>";
        }
 ?>
 </table>
</body>
</html>


지속적인 학습
||
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>学生信息管理</title> <script> function doDel(id) { if(confirm('确认删除?')) { window.location='action.php?action=del&id='+id; } } </script> </head> <body> <?php include ("menu.php"); ?> <h3>浏览学生信息</h3> <table width="350" border="1" cellspacing="0"> <tr> <th>ID</th> <th>姓名</th> <th>性别</th> <th>年龄</th> <th>班级</th> <th>操作</th> </tr> <?php // 1. 链接数据库 header("content-type:text/html;charset=utf8"); $conn=mysqli_connect("localhost","root","root","study"); mysqli_set_charset($conn,"utf8"); //2.执行sql $sql_select = "select * from stu"; //3.data 解析 foreach ( $conn->query($sql_select) as $row) { echo "<tr>"; echo "<th>{$row['id']} </th>"; echo "<th>{$row['name']}</th>"; echo "<th>{$row['sex']} </th>"; echo "<th>{$row['age']} </th>"; echo "<th>{$row['class']}</th>"; echo "<td> <a href='edit.php?id={$row['id']}'>修改</a> <a href='javascript:void(0);' onclick='doDel({$row['id']})'>删除</a> </td>"; echo "</tr>"; } ?> </table> </body> </html>
  • 코스 추천
  • 코스웨어 다운로드
현재 코스웨어를 다운로드할 수 없습니다. 현재 직원들이 정리하고 있습니다. 앞으로도 본 강좌에 많은 관심 부탁드립니다~