br.html
<html>
<head><title>smarty实现换行</title><head>
<body>
<{assign var="flag" value="1"}>
<{section name=loop loop=$log}>
<{if $flag == "1"}>
<{if $smarty.section.loop.index!=0}>
<br/>
<{/if}>
<{assign var="flag" value="2"}>
<{else $flag == 2}>
<{assign var="flag" value="1"}>
<{/if}>
<{$log[loop].title}>
<{/section}>
</body>
</html>
br.php
<?php
include "conn.php";
require("../libs/smarty.class.php");
$smarty = new Smarty();
$smarty->template_dir = 'templates/'
$smarty->compile_dir = 'templates_c/'
$smarty->config_dir = 'configs/'
$smarty->cache_dir = 'cache/'
$smarty->caching = false;
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$sql="select id,logclassid,title from log order by datetime desc limit 0,100";
mysql_query("set names gb2312");
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
$array[]= array("title"=>$row["title"]);
}
$smarty->assign("log", $array);
$smarty->display("br.tpl");
?>