具体显示页面代码如下:
<?php
require_once('../base.php');
global $catalog;
$catalog = $_GET['catalog'];
if($catalog == "0103")
{
$GLOBALS['rows']=5;
}?><?
//列表显示内容
function listAll(){
global $db , $func ,$smarty ;
$selectSql = "select * from $GLOBALS[news_table] where news_type = '$_GET[catalog]' ";
$selectSql .=" order by news_seq desc ";
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//$rs = $db->Execute($selectSql);
$page = $_GET['page'] ? $_GET['page'] : 1;
$nrows = $GLOBALS['rows'];
$rs = $db->PageExecute($selectSql, $nrows, $page);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$rs_arr = $rs->GetArray();
$smarty->assign('rs_arr',$rs_arr );
if($rs->AtFirstPage()){
$prevpage = 1 ;
}else{
$prevpage = $page -1 ;
}
if($rs->AtLastPage()){
$nextpage = $page ;
}else{
$nextpage = $page +1 ;
}
$smarty->assign("prevpage", $prevpage);
$smarty->assign("nextpage", $nextpage);
$smarty->assign("catalog", $GLOBALS[catalog]);
$smarty->assign("func", $func);
}
}#详细内容
function Detail(){
global $db , $func ,$smarty; $selectSql = "select * from $GLOBALS[news_table] where news_id = " . $db->Quote($_GET[newsid]) ." ";
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('row',$row );
$smarty->assign("func", $func);
$smarty->assign("catalog", $GLOBALS[catalog]);
}
}//列表显示内容
function listSearch(){
global $db , $func ,$smarty, $query_var, $keywords;
$selectSql = "select * from $GLOBALS[news_table] where news_type = '$_GET[catalog]' ";
if($query_var=="0"){
$selectSql.=" and news_title like '%$keywords%' ";
}else{
$selectSql.=" and news_content like '%$keywords%' ";
}
$selectSql.=" order by news_id desc ";
//echo $selectSql;
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//$rs = $db->Execute($selectSql);
$page = $_GET['page'] ? $_GET['page'] : 1;
$nrows = $GLOBALS['rows'];
$rs = $db->PageExecute($selectSql, $nrows, $page);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$rs_arr = $rs->GetArray();
$smarty->assign('rs_arr',$rs_arr );
if($rs->AtFirstPage()){
$prevpage = 1 ;
}else{
$prevpage = $page -1 ;
}
if($rs->AtLastPage()){
$nextpage = $page ;
}else{
$nextpage = $page +1 ;
}
$smarty->assign("prevpage", $prevpage);
$smarty->assign("nextpage", $nextpage);
$smarty->assign("catalog", $GLOBALS[catalog]);
$smarty->assign("func", $func);
}
}#显示当前位置
function location(){
global $db , $func ,$smarty, $catalog, $keywords; $selectSql = "select * from $GLOBALS[catalog_table] where cat_code = '" . substr($_GET[catalog],0,2) ."' ";
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('location1',$row[cat_name] );
} $selectSql = "select * from $GLOBALS[catalog_table] where cat_code = " . $db->Quote(substr($_GET[catalog],0,4)) ." ";
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('location2',$row[cat_name] );
}
$smarty->assign('catalog',$catalog );
$smarty->assign('keywords',$keywords );}
location(); if($func=="listAll"){
listAll();
}else if($func=="detail"){
Detail();
}else if($func=="search"){
listSearch();
} $smarty->display('news/index.tpl');
?>
<?php
require_once('../base.php');
global $catalog;
$catalog = $_GET['catalog'];
if($catalog == "0103")
{
$GLOBALS['rows']=5;
}?><?
//列表显示内容
function listAll(){
global $db , $func ,$smarty ;
$selectSql = "select * from $GLOBALS[news_table] where news_type = '$_GET[catalog]' ";
$selectSql .=" order by news_seq desc ";
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//$rs = $db->Execute($selectSql);
$page = $_GET['page'] ? $_GET['page'] : 1;
$nrows = $GLOBALS['rows'];
$rs = $db->PageExecute($selectSql, $nrows, $page);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$rs_arr = $rs->GetArray();
$smarty->assign('rs_arr',$rs_arr );
if($rs->AtFirstPage()){
$prevpage = 1 ;
}else{
$prevpage = $page -1 ;
}
if($rs->AtLastPage()){
$nextpage = $page ;
}else{
$nextpage = $page +1 ;
}
$smarty->assign("prevpage", $prevpage);
$smarty->assign("nextpage", $nextpage);
$smarty->assign("catalog", $GLOBALS[catalog]);
$smarty->assign("func", $func);
}
}#详细内容
function Detail(){
global $db , $func ,$smarty; $selectSql = "select * from $GLOBALS[news_table] where news_id = " . $db->Quote($_GET[newsid]) ." ";
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('row',$row );
$smarty->assign("func", $func);
$smarty->assign("catalog", $GLOBALS[catalog]);
}
}//列表显示内容
function listSearch(){
global $db , $func ,$smarty, $query_var, $keywords;
$selectSql = "select * from $GLOBALS[news_table] where news_type = '$_GET[catalog]' ";
if($query_var=="0"){
$selectSql.=" and news_title like '%$keywords%' ";
}else{
$selectSql.=" and news_content like '%$keywords%' ";
}
$selectSql.=" order by news_id desc ";
//echo $selectSql;
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//$rs = $db->Execute($selectSql);
$page = $_GET['page'] ? $_GET['page'] : 1;
$nrows = $GLOBALS['rows'];
$rs = $db->PageExecute($selectSql, $nrows, $page);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$rs_arr = $rs->GetArray();
$smarty->assign('rs_arr',$rs_arr );
if($rs->AtFirstPage()){
$prevpage = 1 ;
}else{
$prevpage = $page -1 ;
}
if($rs->AtLastPage()){
$nextpage = $page ;
}else{
$nextpage = $page +1 ;
}
$smarty->assign("prevpage", $prevpage);
$smarty->assign("nextpage", $nextpage);
$smarty->assign("catalog", $GLOBALS[catalog]);
$smarty->assign("func", $func);
}
}#显示当前位置
function location(){
global $db , $func ,$smarty, $catalog, $keywords; $selectSql = "select * from $GLOBALS[catalog_table] where cat_code = '" . substr($_GET[catalog],0,2) ."' ";
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('location1',$row[cat_name] );
} $selectSql = "select * from $GLOBALS[catalog_table] where cat_code = " . $db->Quote(substr($_GET[catalog],0,4)) ." ";
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('location2',$row[cat_name] );
}
$smarty->assign('catalog',$catalog );
$smarty->assign('keywords',$keywords );}
location(); if($func=="listAll"){
listAll();
}else if($func=="detail"){
Detail();
}else if($func=="search"){
listSearch();
} $smarty->display('news/index.tpl');
?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货