smarty 循环样式判断

单数行输出红色 双数行输出绿色 应该怎么写
<table>
{foreach from="$info" item="info" }
<tr style="background:red">
<td><strong>{$info.user_name}<strong></td>
<td><strong>{$info.tel}<strong></td>
</tr>
{/foreach}
</tbody></table>
</table>

第1个回答  推荐于2016-12-01
<table>
{foreach from="$info" item="info" name='in'}
{if $smarty.foreach.in.iteration %2 eq 1}
<tr style="background:red">
{else}
<tr style="background:green">
{/if}
<td><strong>{$info.user_name}<strong></td>
<td><strong>{$info.tel}<strong></td>
</tr>

{/foreach}
</tbody></table>
</table>本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网