欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

smarty表格換行實例

 更新時間:2014年12月15日 15:02:11   投稿:shichen2014  
這篇文章主要介紹了smarty表格換行的方法,可實現(xiàn)針對表格的靈活操作,需要的朋友可以參考下

本文實例講述了smarty表格換行的實現(xiàn)方法。分享給大家供大家參考。具體分析如下:

在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}> 后換行 你喜歡換多少就改改參數(shù)就可以了!

復制代碼 代碼如下:
<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 來做換行的例子,但只能作到每行兩條數(shù)據(jù)就換行的效果 只能換兩行

復制代碼 代碼如下:
<table> 
<tr>   
<{foreach item=item from=$items}>     
<td><{$item.name}>     
<{cycle values="</td>,</td></tr><tr>"}>   
<{/foreach}> 
</tr>
</table>

希望本文所述對大家的PHP程序設計有所幫助。

相關文章

最新評論