php的smarty模板section不出数据
php文件:$smarty->assign('book',$book);模板文件:{sectionname=bloop=$book}<tableborder="1"><t...
php文件:$smarty->assign('book',$book);
模板文件:
{section name=b loop=$book}
<table border="1">
<tr>
<td>{$book[b].p_id}</td>
<td>{$book[b].p_name}</td>
<td>{$book[b].p_date}</td>
<td>{$book[b].p_state}</td>
</tr>
{/section}
</table>
运行后表格内不显示数据,print_r($book)显示的结果如下:Array ( [0] => Array ( [0] => Array ( [0] => 41 [p_id] => 41 [1] => 孔雀森林 [p_name] => 孔雀森林 [2] => 2012-08-29 00:00:00 [p_date] => 2012-08-29 00:00:00 [3] => 1 [p_state] => 1 ) ) [1] => Array ( [0] => Array ( [0] => 42 [p_id] => 42 [1] => 射雕英雄传(全四册) [p_name] => 射雕英雄传(全四册) [2] => 2012-08-29 00:00:00 [p_date] => 2012-08-29 00:00:00 [3] => 1 [p_state] => 1 ) ) [2] => Array ( [0] => Array ( [0] => 43 [p_id] => 43 [1] => 诛仙全集 [p_name] => 诛仙全集 [2] => 2012-08-29 00:00:00 [p_date] => 2012-08-29 00:00:00 [3] => 1 [p_state] => 1 ) ) )
请问如何破?
但能出来三个空行 展开
模板文件:
{section name=b loop=$book}
<table border="1">
<tr>
<td>{$book[b].p_id}</td>
<td>{$book[b].p_name}</td>
<td>{$book[b].p_date}</td>
<td>{$book[b].p_state}</td>
</tr>
{/section}
</table>
运行后表格内不显示数据,print_r($book)显示的结果如下:Array ( [0] => Array ( [0] => Array ( [0] => 41 [p_id] => 41 [1] => 孔雀森林 [p_name] => 孔雀森林 [2] => 2012-08-29 00:00:00 [p_date] => 2012-08-29 00:00:00 [3] => 1 [p_state] => 1 ) ) [1] => Array ( [0] => Array ( [0] => 42 [p_id] => 42 [1] => 射雕英雄传(全四册) [p_name] => 射雕英雄传(全四册) [2] => 2012-08-29 00:00:00 [p_date] => 2012-08-29 00:00:00 [3] => 1 [p_state] => 1 ) ) [2] => Array ( [0] => Array ( [0] => 43 [p_id] => 43 [1] => 诛仙全集 [p_name] => 诛仙全集 [2] => 2012-08-29 00:00:00 [p_date] => 2012-08-29 00:00:00 [3] => 1 [p_state] => 1 ) ) )
请问如何破?
但能出来三个空行 展开
展开全部
<table border="1">
{section name=b loop=$book}
<tr>
{sction name=td loop=$book[b]}
<td>{$book[b][td].p_id}</td>
<td>{$book[b][td].p_name}</td>
<td>{$book[b][td].p_date}</td>
<td>{$book[b][td].p_state}</td>
{/section}
</tr>
{/section}
<table border="1">
{foreach from=$book item=b}
<tr>
{foreach from=$b item=td}
<td>{$td.p_id}</td>
<td>{$td.p_name}</td>
<td>{$td.p_date}</td>
<td>{$td.p_state}</td>
{/foreach}
</tr>
{/foreach}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询