前台显示功能
—————————————————————前台显示文件———————————————————————————————————————————————
<?php
include("connectmysql.php");
include("../libs/Smarty.class.php");
$smarty = new Smarty();
$smarty->reInitSmarty("../demo/templates","../demo/templates_c","../demo/configs","../demo/cache");
//$smarty->caching=1;
$array_new = array();
$q = "select * from new order by news_date desc";
$result = mysql_query($q);
while($row = mysql_fetch_assoc($result)){
$array_new[] = $row;
}
$smarty->assign("array_new",$array_new);
$smarty->display('index.tpl');
?>
——————————————————————跳转的文件————————————————————————————————————————————————
<?php
include("../libs/Smarty.class.php");
include("connectmysql.php");
$smarty = new Smarty();
$smarty->reInitSmarty("../demo/templates","../demo/templates_c","../demo/configs","../demo/cache");
$smarty->caching=1;
if(!$smarty->is_cached('show_news.tpl',$_GET['id'])){
$q = 'select id,title,content,news_date,c_name,description from new join category on new.news_cate_id = category.news_cate_id where id='.$_GET["id"];
$result = mysql_query($q);
$row = mysql_fetch_assoc($result);
$smarty->assign("new_details",$row);
}
$smarty->display('show_news.tpl',$_GET["id"])
?>