你的写法有问题.
声明一下看看$array=array();
或者把它写成如下形式:
$array = array(array("newsID"=>1, "newsTitle"=>"第1条新闻"),
               array("newsID"=>2, "newsTitle"=>"第2条新闻"),
               array("newsID"=>3, "newsTitle"=>"第3条新闻"),
               array("newsID"=>4, "newsTitle"=>"第4条新闻"),
               array("newsID"=>5, "newsTitle"=>"第5条新闻"),
               array("newsID"=>6, "newsTitle"=>"第6条新闻")
   );
$smarty->assign('newsArray', $array);
print_r($array);
你的这人例子是从这里来的.你可以参考这个网址:
http://phpx.com/happy/showthread.php?s=cfa4e52aec7429725adf4c70720bbbae&threadid=83987&highlight=smarty

解决方案 »

  1.   

    注意看看哪个$rs的处理!我就是那样做的,反正结果是可以显示的,上面哪个东东是个分页类-----------------------------my example-------------------------------------
    res=$db->query($sql);
    $curr_rows=$db->num_rows($res);
    $total="Total Records:".$p->curr."/".ceil($rows/$pagesize)." pages";
    $pager=$p->output(1);
    $page = new SmartTemplate("showlog.htm"); //实例化模板类
    $page->assign('cssdir',$cssdir);
    $page->assign('jsdir',$jsdir);
    $rslog=array();
    $i=0;
    while($rs=$db->fetch_array($res))

    $rslog[$i]=$rs;
    $rslog[$i]['logtime']=ftime($rs['logtime']);
    $i++;

    }
    $rslog=$rslog;
    $page->assign('rslog',$rslog);
    $page->assign('total',$total);
    $page->assign('pager',$pager);
    $page->assign('url','?action=deletelog');
    $page->output();
    -----------------------------------my template file--------------------------
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>管理日志</title>
    <link href="{cssdir}" rel="stylesheet" type="text/css">
    <SCRIPT LANGUAGE="JavaScript" src="{jsdir}"></SCRIPT>
    </head><body>
    <br>
    <table width="90%"  border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#FFFFFF" class="main">
      <tr>
        <td width="38" bgcolor="#003399"><div align="center">编号</div></td>
        <td width="50" bgcolor="#003399"><div align="center">用户名</div></td>
        <td width="298" bgcolor="#003399"><div align="center">执行脚本</div></td>
        <td width="92" bgcolor="#003399"><div align="center">时间</div></td>
        <td width="104" bgcolor="#003399"><div align="center">userip</div></td>
      </tr>
      <!-- BEGIN rslog --> 
      <tr> 
        <td width="6%" bgcolor="#003366">{logid}</td>
        <td width="10%" bgcolor="#003366">{username}</td>
        <td width="35%" bgcolor="#003366">{actions}</td>
        <td width="24%" bgcolor="#003366">{logtime}</td>
        <td width="15%" bgcolor="#003366">{userip}</td>
      </tr>
     <!-- END rslog -->
    </table>
    <div align="center"><br>
      <br>
      {total}    {pager}    <a class="main" onclick="return __confirm();" href="{url}" title="清除历史记录">清除历史记录</a>
    </div>
    </body>
    </html>