百思不得其解各位大侠帮我
 
第一条为空,后面就正常了。查看数据库没有空记录//php while ($result3 = mysql_fetch_array($query2)) {
$test[] = $result3;
}
$smarty->assign('comments',$test);
$smarty->display('show_comment.tpl');
//smarty tpl<div style="border:1px solid black;padding:20px;width:600px;float:left; margin-top:10px;">
{section name=mysec loop=$comments}
<h5> {$comments[mysec].commentName} said:</h5>
<hr>
<p>{$comments[mysec].commentContent}</p>
<hr><br>
{/section}
</div>

解决方案 »

  1.   

    仅仅是可能:
    section循环从1开始,$comments从$comments[0]开始。换成 begin end呢。
      

  2.   

    2楼能不能再说的清楚一点,我刚开始接触smarty的。
      

  3.   

    先把$test 打出来看是啥数据
      

  4.   

    默认是从0开始的.
    $result3 = mysql_fetch_array($query2)
    =>
    $result3 = mysql_fetch_array($query2, MYSQL_ASSOC)
    试试
      

  5.   

    用isset($comments[mysec])判断一下就行了。