如何用PHP实现 fasttemplate模板循环显示记录

这是我的模板页
<form method="get">
<div class=list_txt >
<ul>
<li><span>{time}</span><div><a href="all.php?id={topic_id}">{topic_title}</a></div></li>
</ul>
</div>
</form>

以下是我的PHP代码

$result = mysql_query("SELECT topic_id,forum_id,topic_title,topic_time from phpbb_topics where forum_id =38 order by topic_time desc ");
$row = mysql_fetch_array($result);
mysql_close($con);

include "./fasttemp/class.FastTemplate.php3";
$tpl = new FastTemplate("./fasttemp");

$tpl->define(array('foo' => "list_txt.html", 'bar' => "bar.tpl"));

$tpl->assign('topic_title', "$row[topic_title]");//获取帖子号,用于“加入讨
$tpl->assign('time', date('Y-m-d', $row['topic_time']));//获取时间

$tpl->parse('pagecontent', "foo");
$tpl->assign('topic_id', "$row[topic_id]");//获取主题号,用于“加入讨
$tpl->parse('main', "foo");

$tpl->FastPrint('main');
?>

以上的循环只能显示一条记录,要怎么改才能循环显示数据库里的所有数据呢
一楼你用的是phplib template吧,我要用的是fasttemplate模板,两者一样吗

<form method="get">
<div class=list_txt >
<ul>

<!-- BEIGN linelist -->
<li><span>{time}</span><div><a href="all.php?id={topic_id}">{topic_title}</a></div></li><!--这里的topic_id就是数据库的相应字段名-->
<!-- END linelist -->
</ul>
</div>
</form>
php :

$tpl->set_file("main","your file name");
$tpl->set_block("main","linelist","line");

while($row=mysqli_fetch_assoc($result)){

$tpl -> set_var($row);
$tpl->parse("line","linelist",true);
}

参考资料:http://www.zaijn.com/category/view.php?id=34

温馨提示:答案为网友推荐,仅供参考