smarty section nested loop usage example, smartysection_PHP tutorial

WBOY
Release: 2016-07-12 08:50:56
Original
895 people have browsed it

Smarty's section nested loop usage example, smartysection

This article describes the use of smarty's section nested loop. Share it with everyone for your reference, the details are as follows:

{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}" 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}
Copy after login

Use $typeList[sec1].shop of sec1 as the loop of sec2

You can get the contents of the array in the shop

Readers who are interested in more Smarty-related content can check out the special topics on this site: "Basic Tutorial for Getting Started with Smarty Templates", "Summary of PHP Template Technology", "Summary of PHP Database Operation Skills Based on PDO", "PHP Operations and Operators" Usage summary", "PHP network programming skills summary", "PHP basic syntax introductory tutorial", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "Summary of Common Database Operation Skills in PHP"

I hope this article will be helpful to everyone’s PHP program design based on smarty templates.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1133056.htmlTechArticlesmarty’s section nested loop usage example, smartysection This article describes the smarty section nested loop usage example. Share it with everyone for your reference, the details are as follows: {section name="s...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template