PHP头条
热点:

smarty 换行实例 表格换行,smarty换行


在 foreach 中加入 key=count

<table>  
<{foreach item=item from=$items key=count}>  
<{if $count is div by 2}><tr>
<{/if}>   
<td><{$item.name}></td>   
<td><{$item.summary}></td>   
<td><{$item.date}></td>  
<{if ($count+1) is div by 2}></tr><{/if}>  
<{/foreach}></table>

每行放置三個 <{$item.name}> 後換行 你喜欢换多少就改改参数就可以了!

<table>  
<tr>  
<{foreach item=item from=$items key=count}>      
<td><{$item.name}></td>  
<{if ($count+1) is div by 3}></tr><tr><{/if}>  
<{/foreach}>  
</tr></table>

另一種利用 cycle 來做換行的例子,但只能作到每行兩筆資料就換行的效果 只能换两行


<table>  
<tr>   
<{foreach item=item from=$items}>      
<td><{$item.name}>      
<{cycle values="</td>,</td></tr><tr>"}>   
<{/foreach}>  
</tr>
</table>

www.phpzy.comtrue/php/30685.htmlTechArticlesmarty 换行实例 表格换行,smarty换行 在 foreach 中加入 key=count table {foreach item=item from=$items key=count} {if $count is div by 2}tr {/if} td{$item.name}/td td{$item.summary}/td td{$item.date}/td {if ($count+1) is div b...

相关文章

PHP之友评论

今天推荐