Home  >  Article  >  Backend Development  >  smarty的section嵌套循环用法示例,smartysection_PHP教程

smarty的section嵌套循环用法示例,smartysection_PHP教程

WBOY
WBOYOriginal
2016-07-12 08:50:56843browse

smarty的section嵌套循环用法示例,smartysection

本文实例讲述了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&#63;id={$typeList[sec1].shop[sec2].id}" target="_blank"><img  src="http://localhost/{$typeList[sec1].shop[sec2].img_url}"    style="max-width:90%"  style="max-width:90%" border="0" alt="smarty的section嵌套循环用法示例,smartysection_PHP教程" ></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相关内容感兴趣的读者可查看本站专题:《smarty模板入门基础教程》、《PHP模板技术总结》、《PHP基于pdo操作数据库技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1133056.htmlTechArticlesmarty的section嵌套循环用法示例,smartysection 本文实例讲述了smarty的section嵌套循环用法。分享给大家供大家参考,具体如下: {section name="s...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn