调试环境:easyphp 5.3.0
问题描述:模板只显示数组的第一列,其他的不显示PHP代码:
<?php
require_once('config/config.php');$arr = array(
        array('id'=>5,'title'=>'title1'),
         array('id'=>8,'title'=>'title2'),
       array('id'=>3,'title'=>'title3')
    );
$smarty->assign('news',$arr);
$smarty->display('test.htm');
?>模板部分代码:
<HTML><HEAD>
<TITLE>测试</TITLE>
</HEAD>
{section name=n loop=$news}
<{$news[n].title}>&nbsp;
<{$news[n].id}><br>
没有数据
{/section}
</html>显示结果:         <5>
没有数据   <8>
没有数据   <3>
没有数据 

解决方案 »

  1.   

    <HTML><HEAD>
    <TITLE>测试</TITLE>
    </HEAD>
    <{section name=n loop=$news}>
    <{$news[n].title}>&nbsp;
    <{$news[n].id}><br>
    没有数据
    <{/section}>
    </html>
      

  2.   

    不会吧 我试了下正常啊  要不你把数组名$arr 改为 $arr[]试试
      

  3.   

    结果是:
    <>   <5>
    <>   <8>
    <>   <3>
    <> 
      

  4.   

    <HTML><HEAD>
    <TITLE>测试</TITLE>
    </HEAD>
    {section name=n loop=$news}
    {$news[n].id}<br>
    {$news[n].titlex}&nbsp;没有数据
    {/section}
    </html>
      

  5.   

    <HTML><HEAD>
    <TITLE>测试</TITLE>
    </HEAD>
    {section name=n loop=$news}
    {$news[n].id}<br>
    {$news[n].titlex}&nbsp;没有数据
    {/section}
    </html>
      

  6.   

    <HTML><HEAD>
    <TITLE>测试</TITLE>
    </HEAD>
    {section name=n loop=$news}
    {$news[n].id}<br>
    {$news[n].title}&nbsp;
    {/section}
    </html>
    谢谢