관리자 목록을 보여주는 PHP 개발 기업 웹사이트 튜토리얼

우리 프레임워크에서는 관리자 관리를 클릭하면 관리자가 표시됩니다. 표시 과정에서 수정 및 삭제 추가를 위한 링크가 제공됩니다. 수정 및 삭제 추가를 클릭하면 다음과 같이 다양한 기능을 완료할 수 있습니다. 사진과 같이

user.png관리자 추가를 클릭하면 해당 페이지에서 수정 및 삭제가 이루어집니다

물론 관리자 추가 페이지에서 정보를 빼내야 합니다.

코드는 다음과 같습니다.

<?php
    require_once('conn.php'); //连接数据库
    $sql = "select * from user order by id desc"; //查询user表中的数据
    $info = mysql_query($sql);
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>展示用户列表</title>
    <style type="text/css">
        .top{height:30px;line-height:30px;float:right;margin-right:15px;}
        .top a{color:red;text-decoration:none;}
        .cont{width:100%;height:300px;float:left;}
        .cont_ct{float:left;}
        table{width:100%;border:1px solid #eee;text-align:center;}
        th{background:#eee;}
        td{width:200px;height:30px;}
    </style>
</head>
<body>
    <div class="top"><a href="addu.php">添加管理员</a></div>

    <div class="cont">
        <table cellspacing="0" cellpadding="0" border="1">
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>密码</th>
                <th>操作</th>
            </tr>
            <?php
                //获取表中的数据
                while($row=mysql_fetch_array($info)){
            ?>
            <tr>
                <td><?php echo $row['id'];?></td>
                <td><?php echo $row['username'];?></td>
                <td><?php echo $row['password'];?></td>
                <td>
                    <a href="modifyu.php?id=<?php echo $row['id'];?>">修改</a>
                    <a href="deluser.php?id=<?php echo $row['id'];?>">删除</a>
                </td>
            </tr>
            <?php
                }
            ?>
        </table>
    </div>
</body>
</html>

페이지 시작 부분에 php 태그를 작성합니다

안에 php 문을 작성합니다

데이터베이스에 연결

사용자 테이블의 정보를 쿼리하고, id에 따라 역순으로 정렬한 후 sql 문을 실행합니다. 아래 while 루프를 사용하여 데이터베이스를 가져옵니다. 정보는 프런트 엔드 페이지에 출력됩니다

Note

: 수정 및 삭제 뒤에는 삭제 및 수정은 항목 삭제와 같은 조건부 항목이어야 하기 때문에 조건이 없으면 프로그램은 어떤 정보가 삭제되더라도 오류가 보고됩니다그래서 수정 및 삭제는 매개변수 id .moduu.php 및 deluser.php 두 파일에서 ID를 얻은 다음 작업을 수행합니다

지속적인 학습
||
<?php require_once('conn.php'); //连接数据库 $sql = "select * from user order by id desc"; //查询user表中的数据 $info = mysql_query($sql); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>展示用户列表</title> <style type="text/css"> .top{height:30px;line-height:30px;float:right;margin-right:15px;} .top a{color:red;text-decoration:none;} .cont{width:100%;height:300px;float:left;} .cont_ct{float:left;} table{width:100%;border:1px solid #eee;text-align:center;} th{background:#eee;} td{width:200px;height:30px;} </style> </head> <body> <div class="top"><a href="addu.php">添加管理员</a></div> <div class="cont"> <table cellspacing="0" cellpadding="0" border="1"> <tr> <th>ID</th> <th>用户名</th> <th>密码</th> <th>操作</th> </tr> <?php //获取表中的数据 while($row=mysql_fetch_array($info)){ ?> <tr> <td><?php echo $row['id'];?></td> <td><?php echo $row['username'];?></td> <td><?php echo $row['password'];?></td> <td> <a href="modifyu.php?id=<?php echo $row['id'];?>">修改</a> <a href="deluser.php?id=<?php echo $row['id'];?>">删除</a> </td> </tr> <?php } ?> </table> </div> </body> </html>
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!