手机
当前位置:查字典教程网 >编程开发 >php教程 >smarty的section嵌套循环用法示例
smarty的section嵌套循环用法示例
摘要:本文实例讲述了smarty的section嵌套循环用法。分享给大家供大家参考,具体如下:{sectionname="sec1"loop=$t...

本文实例讲述了smarty的section嵌套循环用法。分享给大家供大家参考,具体如下:

{section name="sec1" loop=$typeList} <TABLE class=left20 height=25 cellSpacing=0 cellPadding=0 width=624 background=images/indexbg.gif border=0> <TBODY> <TR> <TD class=zi align=left width=554 height=25><FONT color=#ffffff><B>{$typeList[sec1].typeName}</B></FONT></TD> <TD vAlign=top width=70 height=25><a href="hot.html"><IMG src="images/more.gif" width="53" height="25" border=0></a></TD> </TR></TBODY></TABLE> <table cellspacing="0" cellpadding="0"> <tr> {section name="sec2" loop=$typeList[sec1].shop} <td><table cellspacing="0" cellpadding="0"> <tr> <td valign="center" align="middle" width="116"><table cellspacing="0" cellpadding="0"> <tr> <td><a href="show_prop.php?id={$typeList[sec1].shop[sec2].id}" target="_blank"><img src="http://localhost/{$typeList[sec1].shop[sec2].img_url}" width="84" height="88" border="0"></a></td> </tr> </table></td> </tr> <tr> <td align="middle"> <a href="a01.htm">{$typeList[sec1].shop[sec2].name} </a> </td> </tr> <tr> <td align="middle">数量:{$typeList[sec1].shop[sec2].num} 个 </td> </tr> <tr> <td align="middle">价格:{$typeList[sec1].shop[sec2].price} 白金币 </td> </tr> </table></td> {/section} </tr> </table> {/section}

将sec1 的 $typeList[sec1].shop 作为sec2的loop

就可以取到shop其中的数组的内容

希望本文所述对大家基于smarty模板的PHP程序设计有所帮助。

【smarty的section嵌套循环用法示例】相关文章:

php中get_defined_constants函数用法实例分析

php实现的mongodb操作类

用php来检测proxy

PHP中你应该知道的require()文件包含的正确用法

php简单smarty入门程序实例

php中smarty模板条件判断用法实例

php实现CSV文件导入和导出方法

在WIN98下以apache模块方式安装php

PHP中isset与array_key_exists的区别实例分析

PHP设计聊天室步步通

精品推荐
分类导航