请教smartytemplate模板多行多列的输出。
模板a.htm
<table><!-- BEGIN row -->
<tr><!-- BEGIN column -->
<td>{title}<br>{content}</td><!-- END column -->
</tr><!-- END row -->
</table>
查询记录数组集为$artList
这个输出怎么写呀。帮帮忙。
问题点数:20、回复次数:3Top
1 楼ice_berg16(寻梦的稻草人)回复于 2006-05-04 19:30:32 得分 15
/* 函数 tableFormat( $records, $cols=5, $colsKey="TD" )
** 功能 将数据转换为表格格式
** 参数 $records 数组记录
** 参数 $cols 表格中每行显示的记录数
** 参数 $colsKey 数组中每行的键名
*/
function tableFormat( $records, $cols=5, $colsKey="TD" )
{
$ROWS = array();
while( $col = array_splice( $records, 0, $cols ) )
{
$ROWS[][$colsKey] = $col;
}
return $ROWS;
}
以你的为例
假设想输出每行5列
$artList = tableFormat($artList, 5, "column");
$tpl->assign("row", $artList);Top
2 楼zeroleonhart(Strong Point:Algorithm)回复于 2006-05-04 21:23:40 得分 5
需要将查询记录数组集$artList转换成二维数组才可以Top
3 楼weiz315(大熊)回复于 2006-05-05 08:54:12 得分 0
稻草兄弟呀,你的smartyplate用的很精呀。以后多跟你学习了。谢谢两位兄弟。有什么联系方式吗。Top




