It is very bad to use tables in the smarty template to read data cyclically. Where should I add the <tr> tag and where should I add the </tr> tag, if you need to add the colspan label, you will have to worry about it. However, I have already tried to solve this problem. The following is a special record to avoid this situation. Modify the code as needed:
{Section loop = $ student_list name = list} {if $ smarty. section. list. first | $ smarty. section. list. rownum % 5 = 1} <tr >{/ if} <td >{$ student_list [list]. name} </td> {if $ smarty. section. list. last = 1 & $ smarty. section. list. rownum % 5! = 0} <td colspan = "{math equation = x-y x = 5 y = $ smarty. section. list. rownum % 5} "> & nbsp; </td> {/if} {if $ smarty. section. list. last | $ smarty. section. list. rownum % 5 = 0} </tr> {/if} {/section}
Note: The previous example loops through a table with five columns.
Articles you may be interested in
- Smarty loops the table and supplements the table with insufficient td Information
- Extension of the for loop in the smarty Template
- Use php functions in the smarty template and how to use multiple functions for a variable in the smarty Template
- The last record of the volist loop in the thinkphp Template
- Add the latest tag to the information in the smarty Template
- Method for judging null array in the smarty Template
- How to generate a random number in the smarty Template
- How to Use constants defined by define in a program in a smarty Template