【php开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了php开源代码-16_2.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);
//读取首页栏目内容
$rs = $conn->Execute("select id,channel_id,title from article where channel_id = 1");
$rows = "";
while($row = $rs->FetchRow()){
$rows = "·<a href='16_3.php?aid=".$row["channel_id"]."'>".$row["title"]."</a><br>";
}
$smarty->assign("channel_1_t","新闻中心");
$smarty->assign("channel_1_d",$rows);
$rs = $conn->Execute("select title,detail from article where channel_id = 2 limit 0,1");
$row = $rs->FetchRow();
$smarty->assign("channel_2_t",$row["title"]);
$smarty->assign("channel_2_d",$row["detail"]);
$rs = $conn->Execute("select title,detail from article where channel_id = 3 limit 0,1");
$row = $rs->FetchRow();
$smarty->assign("channel_3_t",$row["title"]);
$smarty->assign("channel_3_d",$row["detail"]);
//底部代码
$smarty->assign("footer","<br><font>版本所有.2000-2008</font>");
//调用templates中的index.tpl模板
$smarty->display('index.tpl');
?>