简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

smarty的section嵌套循环用法示例

来源:易贤网   阅读:977 次  日期:2016-08-18 15:23:45

温馨提示:易贤网小编为您整理了“smarty的section嵌套循环用法示例”,方便广大网友查阅!

本文实例讲述了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 class="hongzi" align="middle"> <a href="a01.htm">{$typeList[sec1].shop[sec2].name} </a> </td>

      </tr>

      <tr>

       <td class="zi2" align="middle">数量:{$typeList[sec1].shop[sec2].num} 个 </td>

      </tr>

      <tr>

       <td class="zi2" align="middle">价格:{$typeList[sec1].shop[sec2].price} 白金币 </td>

      </tr>

    </table></td>

{/section}

    </tr>

</table>

{/section}

将sec1 的 $typeList[sec1].shop 作为sec2的loop 就可以取到shop其中的数组的内容

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

更多信息请查看网络编程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:php获取一定范围内取N个不重复的随机数
下一篇:PHP引用返回用法示例
易贤网手机网站地址:smarty的section嵌套循环用法示例
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!