亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

管理者リストを表示する PHP 開発企業(yè) Web サイトのチュートリアル

私たちのフレームワークでは、管理者管理をクリックすると、表示プロセス中に、変更と削除を追加するためのリンクが表示されます。クリックして変更と削除を追加すると、次のようなさまざまな機(jī)能を?qū)g行できます

。図に示すように

user.png

クリックして管理者を追加すると、管理者の追加ページに移動します。変更と削除はそれぞれのページで行われます

もちろん、から情報を取り出す必要があります。データベースを取得して表示します

コードは次のとおりです:

<?php
    require_once('conn.php'); //連接數(shù)據(jù)庫
    $sql = "select * from user order by id desc"; //查詢user表中的數(shù)據(jù)
    $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
                //獲取表中的數(shù)據(jù)
                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 ステートメントを?qū)g行します。以下の while ループを使用してデータベースを取得します。情報はフロントエンド ページに出力されます

: 変更と削除の後には、 ID の削除と変更は項(xiàng)目の削除などの條件付きである必要があるため、條件がない場合、どの情報が削除されたかに関係なく、プログラムはエラーを報告します

したがって、変更と削除は、パラメータ id 。modifyu.php と deluser.php の 2 つのファイルから ID を取得し、操作を?qū)g行します

學(xué)び続ける
||
<?php require_once('conn.php'); //連接數(shù)據(jù)庫 $sql = "select * from user order by id desc"; //查詢user表中的數(shù)據(jù) $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 //獲取表中的數(shù)據(jù) 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>