if.tpl
<html>
<head>
<title>单元格TD换行</title>
</head>
<body style="margin:0px;">
<table border=1>
<Tr>
<{section name=loop loop=$log step=1}>
<{if $smarty.section.loop.index % 2 == 0 and $smarty.section.loop.index!=0}>
</Tr>
<Tr>
<{/if}>
<td height="24">
<{$log[loop].title}>
</td>
<{/section}>
</Tr>
</table>
</body>
</html>
if.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,6";
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("if.tpl");
?>