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

PHP開發(fā)企業(yè)網(wǎng)站教程之展示管理員列表

在我們框架里面,當(dāng)我們點擊管理員管理的時候,應(yīng)該展示管理員,展示的過程中會給出,添加 修改,刪除的連接,通過點擊添加修改,刪除,從而完成各種功能

如下圖所示

user.png

當(dāng)點擊添加管理員,到添加管理員頁面,修改和刪除都是到各自的頁面

當(dāng)然,信息時需要我們從數(shù)據(jù)庫取出來,然后展示

代碼如下:

<?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標(biāo)簽

內(nèi)部寫上php語句

連接數(shù)據(jù)庫

查詢? user 表的信息,根據(jù) id 進行倒排序,然后執(zhí)行? sql?? 語句, 我們在下面使用while 循環(huán),來取出數(shù)據(jù)庫信息,并輸出到前端頁面

注意 :修改 和 刪除們在后面都跟著輸出了一個? id?? 因為刪除和修改,都是要有條件的,比如刪除那條,如果沒有條件,程序是不知道刪除哪條信息的,就會報錯

所以我們的修改刪除上都會輸出一個參數(shù)?? id?? 在modifyu.php 和 deluser.php? 倆個文件上進行獲取? id? 然后在去執(zhí)行操作

繼續(xù)學(xué)習(xí)
||
<?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>
提交重置代碼