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

列表展示

向數(shù)據(jù)庫(kù)中添加完數(shù)據(jù)之后,接下來我們就希望將數(shù)據(jù)庫(kù)中的數(shù)據(jù)展示在我們的前臺(tái)頁(yè)面中,這就是我們的展示功能。

首先,想要將數(shù)據(jù)庫(kù)中的數(shù)據(jù)展示出來,我們就是要連接我們的數(shù)據(jù)庫(kù),之前提到過,用到連接數(shù)據(jù)庫(kù)代碼的地方會(huì)很多,每用一次就寫一遍會(huì)很麻煩,我們重新創(chuàng)建一個(gè)文件,將連接數(shù)據(jù)庫(kù)寫進(jìn)去,接著調(diào)用就可以了。

<?php
session_start();
header("content-type:text/html;charset=utf-8");
require 'config.php';
?>

將新文件名稱取名為config.php,直接引用就行了

接下來就是從數(shù)據(jù)庫(kù)中查詢數(shù)據(jù),將查到的數(shù)據(jù)展示在前端頁(yè)面上。

<?php
$SQL = "select * from list";//設(shè)置查詢指令
$result=mysqli_query($link,$SQL);//執(zhí)行查詢
?>

將數(shù)據(jù)從list數(shù)據(jù)表中查出,接下來就是顯示在前端頁(yè)面了,我們來看下前端文件。

<?php
while($row=mysqli_fetch_assoc($result))
  ?>
  <tr>
    <td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id" value="" /><?php echo $row['id'];?></td>
    <td><span><?php echo $row['author'];?></span></td>
    <td width="10%"><img src="<?php echo $row['image'];?>" alt="" width="70" height="50" /></td>
    <td width="30%"><span><?php echo $row['content'];?></span></td>
    <td><span>首頁(yè)</span></td>
    <td><span><?php echo $cat_array[$row['cid']];?></span></td>
    <td><span>2016-07-01</span></td>
    <td><div class="button-group">
        <a class="button border-main" href="edit.php?id=<?php echo $row['id']?>">
            <span class="icon-edit"></span> 修改</a>
        <a class="button border-red" href="del.php?idD=<?php echo $row['id']?>" onclick="return del(1,1,1)">
            <span class="icon-trash-o"></span>刪除</a>
    </div>
    </td>
  </tr>
<?php endwhile;?>

我們只需要將查詢的數(shù)據(jù)在前端頁(yè)面循環(huán)展示出來就行。

我們將查詢出來的值以數(shù)組的形式賦值給$row,通過while循環(huán)出來。在前端頁(yè)面對(duì)應(yīng)的地方以<?php echo $row['']?>的形式循環(huán)出來。這樣我們的展示頁(yè)面就算是做完了。

下面一節(jié)我們會(huì)說一下分頁(yè)和關(guān)鍵詞搜索。

繼續(xù)學(xué)習(xí)
||
<?php session_start(); header("content-type:text/html;charset=utf-8"); require 'config.php'; $SQL = "select * from list";//設(shè)置查詢指令 $result=mysqli_query($link,$SQL);//執(zhí)行查詢 ?> <!DOCTYPE html> <html lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="renderer" content="webkit"> <title></title> <link rel="stylesheet" href="css/pintuer.css"> <link rel="stylesheet" href="css/admin.css"> <script src="js/jquery.js"></script> <script src="js/pintuer.js"></script> </head> <body> <form method="get" action="" id="listform"> <div class="panel admin-panel"> <div class="panel-head"><strong class="icon-reorder"> 內(nèi)容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div> <div class="padding border-bottom"> <ul class="search" style="padding-left:10px;"> <li> <a class="button border-main icon-plus-square-o" href="add.php"> 添加內(nèi)容</a> </li> <li> <select name="cid" class="input" style="width:200px; line-height:17px;" onchange="changesearch()"> <option value="">請(qǐng)選擇分類</option> <?php foreach($cat_array as $k=>$vo){ echo "<option value='{$k}'".($k==$_GET['cid']?' selected':'').">{$vo}</option>"; } ?> </select> <li> <input type="text" placeholder="請(qǐng)輸入搜索關(guān)鍵字" name="key" class="input" style="width:250px; line-height:17px;display:inline-block" value="<?php echo $_GET[key];?>"/> <input type="submit" name="sub" class="button border-main icon-search" value="搜索" /> </li> </ul> </div> <table class="table table-hover text-center"> <tr> <th width="100" style="text-align:left; padding-left:20px;">ID</th> <th width="10%">作者</th> <th>圖片</th> <th>內(nèi)容</th> <th>評(píng)論</th> <th>分類名稱</th> <th width="10%">發(fā)布時(shí)間</th> <th width="310">操作</th> </tr> <?php while($row=mysqli_fetch_assoc($result)): ?> <tr> <td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id" value="" /><?php echo $row['id'];?></td> <td><span><?php echo $row['author'];?></span></td> <td width="10%"><img src="<?php echo $row['image'];?>" alt="" width="70" height="50" /></td> <td width="30%"><span><?php echo $row['content'];?></span></td> <td><span>首頁(yè)</span></td> <td><span><?php echo $cat_array[$row['cid']];?></span></td> <td><span>2016-07-01</span></td> <td><div class="button-group"> <a class="button border-main" href="edit.php?id=<?php echo $row['id']?>"> <span class="icon-edit"></span> 修改</a> <a class="button border-red" href="del.php?idD=<?php echo $row['id']?>" onclick="return del(1,1,1)"> <span class="icon-trash-o"></span>刪除</a> </div> </td> </tr> <?php endwhile;?> </html>
提交重置代碼