smarty实现单元格换行

发布时间:2009-08-15 11:58:16 阅读:912次

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");
?>

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
上一篇:smarty实现换行

转载请注明:smarty实现单元格换行 出自老鄢博客 | 欢迎分享