分類資訊分頁列表程式編寫例子


分類資訊分頁清單程式寫範例# 程式碼編寫# 存放目錄格式:# #
外掛程式存放目錄用: /e/extend/infolist/
外掛程式模板存放目錄用: /e/extend/infolist/template/
# 所需程式檔案:# #
# #
/e/extend/infolist/index.php主程式檔案
/e/extend/infolist/template/index.temp.php主程式模板檔

# #
程式目錄 模板目錄
    主程式檔案內容(/e/extend/infolist/index.php#):
#

<?php
# require('../../class/connect.php'); //引入資料庫設定檔與公用函數檔
require('../../class/db_sql.php'); //引入資料庫操作檔
require('../../data/dbcache/class.php'); //引入欄位快取檔案
require '../'.LoadLang("pub/fun.php"); //引入分頁語言包檔案
$link=db_connect(); //連線MYSQL
# $empire=new mysqlquery(); //宣告資料庫操作類別
$editor=1; //宣告目錄層級

//-------- 分頁參數 --------
$page=(int)$_GET['page'];
$start=0;
$line=10; //每頁顯示記錄數
$page_line=8; //每頁顯示分頁連結數
$offset=$page*$line; //總偏移量

//-------- 查詢SQL --------
//取得資訊總數
$totalquery="select count(*) as total from {$dbtbpre}ecms_info where checked=1";
$num=$empire->gettotal($totalquery);
//select查詢SQL
# $query="select * from {$dbtbpre}ecms_info where checked=1";
$query.=" order by newstime desc limit $offset,$line";
$sql=$empire->query($query);

#

$listpage=page1($num,$line,$page_line,$start,$page,$search);//取得分頁導覽
require('template/index.temp.php'); //導入模板檔

#

db_close(); //關閉MYSQL連結
$empire=null; //取消操作類別變數
?>


主程式範本檔案內容(/e/extend/infolist/template/index.temp.php):
;
    <td height="25"><strong>分類資訊分頁清單:</strong></td>
  </tr>
  <tr>
<?php
# if(!defined('InEmpireCMS'))
{
        exit();
}
?>




<title>分類資訊分頁清單</title>
<link href="template/images/style.css" rel= "樣式表" type ="text/css">








<表格寬度=「500」邊框=“0”對齊=“中心”cellpadding=“3”cellspacing=“1”bgcolor=“#CCCCCC”>
  

<表 寬度=“100%”邊框=“0”儲存格間距=“0” cellpadding="0">
while($r=$empire->fetch($sql)) //循環取得查詢記錄
{
# $titleurl=sys_ReturnBqTitleLink($r); //標題連結
?>
<tr>

</a>] <a href="<?=$titleurl?>"目標=“_blank”>

</a></td>

                <?=date('Y-m-d',$r[newstime])?>
                </div></td>
                </tr>
                <?php
#                 }
                ?>
#                 </table>

</td>
  </tr>
  <tr>
    <td height="30" bgcolor="#FFFFFF">
      <divdiv;" >
        <?=$listpage?>
      </div></td>
  </tr>
</table>
</body>
#</html>
說明:模板可用Dreamweaver視覺化製作。其中藍色部分程式碼為不允許直接存取模板檔案的作用。   存取Hello World外掛程式檔案主程式:/e/extend/newnews/index.php# #