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

PHP開(kāi)發(fā) 新聞發(fā)布系統(tǒng)之新聞列表頁(yè)面

創(chuàng)建新聞列表頁(yè) new_list.php 文件

我們發(fā)布的所有新聞都會(huì)在本頁(yè)面顯示


首先先將數(shù)據(jù)從數(shù)據(jù)庫(kù)查找出來(lái),代碼如下


<?php
header("content-type:text/html;charset=utf8");
$conn=mysqli_connect("localhost","root","root","News");
mysqli_set_charset($conn,'utf8'); //設(shè)定字符集
$sql="select * from new";
$que=mysqli_query($conn,$sql);
?>

數(shù)據(jù)查出來(lái)了,我們要讓我們的數(shù)據(jù)在HTML頁(yè)面顯示,需要用到HTML和PHP語(yǔ)言混編

代碼如下

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>PHP中文網(wǎng)</title>
    <style>
        table{
            margin-top: 10px;
        }
    </style>
</head>
<body>
<a href="new.html">返回發(fā)布新聞</a>
<table border="1" cellspacing="0" width=360 >
    <tr>
        <th>編號(hào)</th>
        <th>文章標(biāo)題</th>
        <th>文章內(nèi)容</th>
        <th>編輯文章</th>
        <th>發(fā)布時(shí)間</th>
    </tr>
    <?php
    while($row=mysqli_fetch_array($que)){
    ?>
    <tr>
        <td><?php echo $row['id'];?></td>
        <td><?php echo $row['title']?></td>
        <td><?php echo $row['content']?></td>
        <td>
            <a href="new_ed.php?id=<?php echo $row['id']?>">修改</a>
            <a href="new_del.php?id=<?php echo $row['id']?>">刪除</a>
        </td>
        <td><?php echo $row['cre_time']?></td>
        <?php }
        ?>
    </tr>
</table>
</body>
</html>

new_list.php 文件完整代碼如下

<?php
header("content-type:text/html;charset=utf8");
$conn=mysqli_connect("localhost","root","root","News");
mysqli_set_charset($conn,'utf8'); //設(shè)定字符集
$sql="select * from new";
$que=mysqli_query($conn,$sql);
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>PHP中文網(wǎng)</title>
    <style>
        table{
            margin-top: 10px;
        }
    </style>
</head>
<body>
<a href="new.html">返回發(fā)布新聞</a>
<table border="1" cellspacing="0" width=360 >
    <tr>
        <th>編號(hào)</th>
        <th>文章標(biāo)題</th>
        <th>文章內(nèi)容</th>
        <th>編輯文章</th>
        <th>發(fā)布時(shí)間</th>
    </tr>
    <?php
    while($row=mysqli_fetch_array($que)){
    ?>
    <tr>
        <td><?php echo $row['id'];?></td>
        <td><?php echo $row['title']?></td>
        <td><?php echo $row['content']?></td>
        <td>
            <a href="new_ed.php?id=<?php echo $row['id']?>">修改</a>
            <a href="new_del.php?id=<?php echo $row['id']?>">刪除</a>
        </td>
        <td><?php echo $row['cre_time']?></td>
        <?php }
        ?>
    </tr>
</table>
</body>
</html>

上面的代碼就可以把我們發(fā)布所有的新聞以表格的形式在HTML頁(yè)面展示出來(lái)




Weiter lernen
||
<a href="new.html">返回發(fā)布新聞</a> <table cellspacing="0" border="1" width="360"> <tbody><tr> <th>編號(hào)</th> <th>文章標(biāo)題</th> <th>文章內(nèi)容</th> <th>編輯文章</th> <th>發(fā)布時(shí)間</th> </tr> <tr> <td>1</td> <td>你好嗎</td> <td>現(xiàn)在的你過(guò)的好嗎</td> <td> <a href="new_ed.php?id=1">修改</a> <a href="new_del.php?id=1">刪除</a> </td> <td>2016-11-03 09:31:26</td> </tr> </tbody></table>
einreichenCode zurücksetzen