Smarty Example of section nested loops usage _php instance

Source: Internet
Author: User
Tags php template smarty template

The examples in this article describe the section nested loops usage of smarty. Share to everyone for your reference, specific as follows:

 {section name= "SEC1" loop= $typeList} <table class=left20 height=25 cellspacing=0 cell padding=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>& lt;/font></td> <td valign=top width=70 height=25><a href= "hot.html ></a></td> </TR></TBODY></TABLE> <ta" ble cellspacing= "0" cellpadding= "0" > <tr> {section name= "sec2" loop= $typeList [Sec1].shop} <td><t Able 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 "></ a></td> </tr> </table></td> </tr> <tr> <TD cl ass= "Hongzi" align= "middle" > <a href= "a01.htm" >{$typeList [Sec1].shop[sec2].name} </a> </td>
      ;/tr> <tr> <td class= "Zi2" align= "middle" > Quantity: {$typeList [Sec1].shop[sec2].num} </td> </tr> <tr> <td class= "Zi2" align= "Middle" > Price: {$typeList [sec1].shop[sec2].price} white gold coins ;/td> </tr> </table></td> {/section} </tr> </table> {/section} 

SEC1 the $typeList [sec1].shop as the loop of SEC2

You can take the contents of the array in the shop

More interested in smarty related content readers can view the site topics: "Smarty Template Primer Tutorial", "PHP Template Technology Summary", "PHP based on PDO Operation Database Skills summary", "PHP Operations and Operator Usage Summary", "PHP Network Programming Skills Summary", " Introduction to PHP Basic Grammar, "Introduction to PHP object-oriented programming", "PHP string (String) Usage Summary", "Php+mysql Database Operations Tutorial" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design based on Smarty template.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.