您的位置:首页 > 编程语言 > PHP开发

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 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: