在html页面 smarty如何实现i++
如何把下面这段C#代码翻译成smarty下的代码?
<% int i_count = 0; foreach (GridViewRow row in this.GridView1.Rows) { if (i_count%4 == 0) {%> <div>.1..<div><% } else {%> <div>.2..<div><% } i_count ++ ; }%> 我写的是这样,但是error
{assign var="i_count"} {foreach from=$row item=item} {if $i_count mod 4} <div>.2..<div> {else} <div>.1..<div> {/if} {$i_count + 1 } {/foreach} 请问如何写?是我i++写错了吗
html5动态显示媒体视频播放器代码,这个我们在企业网站或者教学网站会用到,教学网站,有一些视频要播放,那么就会用到播放器,可以参考源码,看看播放器的效果是如何实现的,php中文网推荐下载!
回复讨论(解决方案)
你为什么要这样写? smarty foreach 里面可以获取当前key 的 {foreach from=$var key=k item=v}
这个k就是了 呵呵
{assign var="i_count" value=0} {foreach from=$row item=item} {if $i_count mod 4} <div>.2..<div> {else} <div>.1..<div> {/if} {assign var="i_count" value=$i_count+1} {/foreach}没测试, 不行的话就把$i_count+1用``引起来
Plain Text code?1234567891011121314{assign var="i_count" value=0} {foreach from=$row item=item} {if $i_count mod 4} ……
貌似要''引起来,但是为什么我的代码就第一次执行第一个div里的,后面都执行第二个div里的内容?
{if $i_count mod 4 == 0} <div>.1..<div> {else} <div>.2..<div> {/if}
{foreach from=$row item=item key=i_count} {if $i_count mod 4} <div>.2..<div> {else} <div>.1..<div> {/if}
{foreach from=$row item=item key=i_count}{if ($i_count mod 4)==0}<div>.2..<div>{else}<div>.1..<div>{/if} 这句可以这么写.
{if ($i_count mod 4) eq 0}









