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.