【php开源代码栏目提醒】:以下是网学会员为您推荐的php开源代码-16_3.php,希望本篇文章对您学习有所帮助。
<?php
//引用公用文件
include_once("16_1.php");
//初始化Smarty对象
$smarty = new Smarty;
$smarty->compile_check = true;
//设置模板中标签对应的数据
$smarty->assign("css","<link href=\"templates/style.css\" rel=\"stylesheet\" type=\"text/css\" />");
$smarty->assign("header","<br><font size=20>内容管理系统</font>");
//读取菜单内容
$rs = $conn->Execute("select id,channel_title,channel_link from channel");
$menu = "<ul>";
while(!$rs->EOF){
if($rs->Fields("channel_link")!=""){
$menu .="<li><a href='".$rs->Fields("channel_link")."'>".$rs->Fields("channel_title")."</a></li>";
}else{
$menu .="<li><a href='16_3.php?cid=".$rs->Fields("id")."'>".$rs->Fields("channel_title")."</a></li>";
}
$rs->MoveNext();
}
$menu .="</ul>";
$smarty->assign("menu",$menu);
//根据用户提交的数据,判断显示单个文章内容,还是显示指定栏目中的文章
if(isset($_GET["cid"]) and $_GET["cid"]!=""){
$rs = $conn->Execute("select title,detail,pub_time from article where channel_id = '".$_GET["cid"]."'");
$row = $rs->FetchRow();
$smarty->assign("title",$row["title"]);
$smarty->assign("detail",$row["detail"]);
$smarty->assign("time",$row["pub_time"]);
}elseif(isset($_GET["aid"]) and $_GET["aid"]!=""){
$rs = $conn->Execute("select title,detail,pub_time from article where id = '".$_GET["cid"]."'");
$row = $rs->FetchRow();
$smarty->assign("title",$row["title"]);
$smarty->assign("detail",$row["detail"]);
$smarty->assign("time",$row["pub_time"]);
}
//底部代码
$smarty->assign("footer","<br><font>版本所有.2000-2008</font>");
//使用对象方法,显示构建后的模板
$smarty->display('content.tpl');
?>
上一篇:
16_2.php
下一篇:
Function GetIp(IP) 获得ip asp