author:php.cn update time:2022-04-11 14:11:14
Classified information paging list program writing example
Category information paging list program writing example |
Program code writing |
Storage directory format: |
Plug-in program storage directory: |
/e/extend/infolist/ |
Plug-in template storage directory uses: |
/e/extend/infolist/template/ |
|
|
Required program files: |
/e/extend/infolist/index.php |
Main program file |
/e/extend/infolist/template/index.temp.php |
Main program template file |
Program Directory |
Template Directory |
![](img/showinfolist1.jpg) |
![](img/showinfolist2.jpg) |
|
|
|
|
Main program file content(/e/extend/infolist/index.php):
<?php
require('../../class/connect.php'); //Introduce database configuration files and public function files
require('../../class/db_sql.php'); //Introduce database operation files
require('../../data/dbcache/class.php'); //Introduce column cache files
require '../'.LoadLang("pub/fun.php"); //Introduce paging language pack file
$link=db_connect(); //Connect to MYSQL
$empire=new mysqlquery(); //Declare database operation class
$editor=1; //Declare directory hierarchy
//--------Paging parameters --------
$page=(int)$_GET['page'];
$start=0;
$line=10; //Display number of records per page
$page_line=8; //Display the number of paging links per page
$offset=$page*$line; //Total offset
//-------- Query SQL --------
//Get the total number of information
$totalquery="select count(*) as total from {$dbtbpre}ecms_info
where checked=1";
$num=$empire->gettotal($totalquery);
//select query 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);//Get paging navigation
require('template/index.temp.php'); //Import template file
db_close(); //Close the MYSQL link
$empire=null; //Cancel operation class variables
?> |
|
Main program template file content(/e/extend/infolist/template/index.temp.php):
<?php
if(!defined('InEmpireCMS'))
{
exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>分类信息分页列表</title> <link href="template/images/style.css" rel="stylesheet" type="text/css"> </head> <body> <br> <br> <br> <table width="500" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td height="25"><strong>分类信息分页列表:</strong></td> </tr> <tr>
<td height="25" bgcolor="#FFFFFF">
<table
width="100%" border="0" cellspacing="0"
cellpadding="0">
<?php
while($r=$empire->fetch($sql))
//循环获取查询记录
{
$titleurl=sys_ReturnBqTitleLink($r);
//标题链接
?>
<tr>
<td width="74%"
height="25">
<img src="template/images/arrow.gif" border="0"
align="absmiddle"> [<a href="<?=$public_r[newsurl]?>e/action/ListInfo.php?classid=<?=$r[classid]?>&ph=1&myarea=<?=$r[myarea]?>"><?=$r[myarea]?></a>]
<a href="<?=$titleurl?>" target="_blank">
<?=esub(stripslashes($r[title]),32)?>
</a></td>
<td width="26%"><div
align="center"> <?=date('Y-m-d',$r[newstime])?>
}
?>
</td> </tr> <tr> <td height="30" bgcolor="#FFFFFF"> <div class="epages" >
<?=$listpage?>
</div></td> </tr></table></body> </html>
| Note: The template can be visually produced with Dreamweaver. The blue part of the code does not allow direct access to the template file.
|
| Access the main program of the Hello World plug-in file: /e/extend/newnews/index.php
|
|