smarty实现换行

发布时间:2009-08-15 11:56:57 阅读:1151次

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

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

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

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