首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

smarty 怎么实现i++

2013-05-02 
smarty 如何实现i++在html页面smarty如何实现i++如何把下面这段C#代码翻译成smarty下的代码?%int i_count

smarty 如何实现i++
在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++写错了吗
 
[解决办法]

{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用``引起来
[解决办法]
{foreach from=$row item=item key=i_count}
                  
                          {if $i_count mod 4}
                            
                                 <div>.2..<div>


                          
                          {else}
                             
                                 <div>.1..<div>
                           {/if}


[解决办法]
这句可以这么写.

{if ($i_count mod 4) eq 0}

热点排行