- 论坛徽章:
- 0
|
业余PHP多年(别看我的注册日期,菜鸟一个),一直徘徊在菜鸟阶段,写的程序毫无结构可言
参考了一些PHP程序,发现在index.php/list.php等文件中根本找不到一个SQL语句,全部是封闭在类中的,看不太懂,
在此请各位大侠推荐一讲究结构、代码清晰的PHP程序以供学习之用。
下面附上我以前写的一文件应试可知我的水平之菜(勿见笑):
文件名list.php
<?php
include_once('./init.php');
$tid = $_GET['tid'];
$page = isset($_GET['page'])?$_GET['page']:1;
$cacheid = $tid.'-'.$page;
//get type array
if (!$t->is_cached('list.htm',"list|$cacheid"))
{
//list
$sql = "select id,name,addtime,hit,size from {$dbprefix}bt where tid='$tid' order by addtime desc";
$dbpage = $db->page($sql,$page,$lst_lst_num);
$list = $dbpage['rs'];
if (!empty($list))
{
$t->assign('list',$list);
}
//pagebar
$t->assign('page',$page);
$t->assign('pagecount',$dbpage['count']);
$t->assign('recount',$dbpage['recount']);
$t->assign('pagesize',$lst_lst_num);
$pagebar = pagebar($dbpage['recount'],$lst_lst_num);
$pagebar = preg_replace("/list.php?page=([0-9]+)/is","list-$1.htm",$pagebar);
$pagebar = preg_replace("/list.php?tid=([0-9]+)&page=([0-9]+)/is","list$1-$2.htm",$pagebar);
$t->assign('pagebar',$pagebar);
//title
$t->assign('title',$arType[$tid]);
//nav
$t->assign('tid',$tid);
$t->assign('tname',$arType[$tid]);
}//is_cached
//
$t->display('list.htm',"list|$cacheid");
?>
|
|