It is a bad thing to use tables to read data in a loop in smarty templates. Where should you add
tags and where should you add
tags? It’s easy to say. If you encounter The kind that requires adding the colspan tag is really troublesome. However, I have already found a way to solve this problem. I will record it below in case I encounter this situation again. The specific code is as shown below and needs to be modified according to the actual situation:
{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}"> </td>
{/if}
{if $smarty.section.list.last || $smarty.section.list.rownum%5==0}</tr>{/if}
{/section}
Note: The above example loops through a five-column table
Articles you may be interested in
- smarty loops the table and supplements the situation when the table td is insufficient
- Extension plug-in for for loop in smarty template
- Using php functions in smarty template and how to use multiple functions for one variable in smarty template
- Judging the last record of volist loop in thinkphp template
- Add the latest tag to information in smarty template
- How to determine if the array is empty in smarty template
- How to generate random numbers in smarty template
- In the program How to use constants defined by define in smarty templates
http://www.bkjia.com/PHPjc/764169.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764169.htmlTechArticleIt is a bad thing to use tables to read data in a loop in the smarty template. Where should you add tr tags? , it’s easy to say where to add the /tr tag. If you encounter that kind of situation, you need to add the colspan tag...
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