php的smarty循环
2009-05-06 13:14
183 查看
<?php
require_once("include/config_base.php");
require 'libs/Smarty.class.php';
$db = new DedeSql(false);
$smarty = new Smarty;
$smarty->compile_check = true;
$db->SetQuery("Select id,title From #@__archives where iscommend=11 order by id desc limit 0,8");
$db->Execute();
while($nrow = $db->GetObject())
{
$news_list[]=array("id"=>$nrow->id,"title"=>mb_substr($nrow->title,0,15,'gbk'));
}
$str=@file_get_contents("http://weather.265.com/weather.htm");
$str=str_replace("<scrīpt>","</body>",$str);
$smarty->assign("news ",$ news_list);
$smarty->assign("weatherstr",$str);
$smarty->display('index.html');
?>
Index.html
循环{section name=loop loop=$news}
<a href="plus/view.php?aid={$news[loop].id}">{$news[loop].title}</a><br />
{/section}
天气{$weatherstr }
require_once("include/config_base.php");
require 'libs/Smarty.class.php';
$db = new DedeSql(false);
$smarty = new Smarty;
$smarty->compile_check = true;
$db->SetQuery("Select id,title From #@__archives where iscommend=11 order by id desc limit 0,8");
$db->Execute();
while($nrow = $db->GetObject())
{
$news_list[]=array("id"=>$nrow->id,"title"=>mb_substr($nrow->title,0,15,'gbk'));
}
$str=@file_get_contents("http://weather.265.com/weather.htm");
$str=str_replace("<scrīpt>","</body>",$str);
$smarty->assign("news ",$ news_list);
$smarty->assign("weatherstr",$str);
$smarty->display('index.html');
?>
Index.html
循环{section name=loop loop=$news}
<a href="plus/view.php?aid={$news[loop].id}">{$news[loop].title}</a><br />
{/section}
天气{$weatherstr }
相关文章推荐
- php smarty 二级分类代码和模版循环例子
- smarty 截取字符串,调用php中的方法,foreach循环
- php smarty foreach循环注意
- php中smarty区域循环的方法
- php的smarty循环
- smarty 截取字符串,调用php中的方法,foreach循环
- php smarty 二级分类代码和模版循环例子
- PHP 5.3 Smarty 实现双层循环
- php smarty 二级分类代码和模版循环例子
- php smarty :smarty在页面控制循环次数(小知识点)
- php中smarty区域循环的方法
- PHP中使用smarty循环
- php smarty区域循环方法
- php的smarty的foreach以及section循环方法!
- php学习 之 Smarty 逻辑判断 和 循环
- smarty模板中传值给php变量 从而实现不同的循环值
- smarty如何完美兼容php5.5和preg_replace_callback如何替换preg_replace
- PHP中使用Smarty模板目录结构配置
- smarty中可以使用php 函数来做modifier