文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Smarty的嵌套循环

Smarty的嵌套循环

时间:2008-04-18  来源:慕良文王


?php
include_once("./smarty/Smarty.class.php");
include_once("./lib/conn.php");
$s = new Smarty;
//$s->caching = true;//开启缓存功能
$s->template_dir = './tpl';
$s->compile_dir = './compile';
$s->cache_dir = './cache';
$sql="select * from class";
$re=mysql_query($sql);
while($k=mysql_fetch_array($re))
{   
    $sql="select * from content where class=$k[id]";
    $ree=mysql_query($sql);
    $news=array();
    while($sub=mysql_fetch_array($ree))
    {   
        $news[]=$sub;
    }
    $k[news_list]=$news;
    $cat_news[]=$k;
}
$s->assign("ss",$cat_news);
$s->display("main.html");
?>
               
               
               
{foreach item=list from=$ss}
    {$list.class_name}br />
    {foreach item=sub_list from=$list.news_list}
          {$sub_list.title}br />
    {/foreach}
{/foreach}


相关阅读 更多 +
排行榜 更多 +
西安交大通

西安交大通

生活实用 下载
长江云通

长江云通

生活实用 下载
translatez

translatez

生活实用 下载