html_table函數(shù)
html_table函數(shù):
自定義函數(shù) html_table 將數(shù)組中的數(shù)據(jù)填充到 HTML 表格中. cols 屬性決定表格有多少列.?
table_attr , tr_attr 和 td_attr 屬性決定表格中 tr 和 td 標(biāo)簽的一些附加屬性.?
如果 tr_attr 和 td_attr 屬性值為數(shù)組,將輪流使用其中的值.?
如果指定了 trailpad 屬性,將在表尾最后一行附加一些數(shù)據(jù).
eg:
index.php:
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('data',array(1,2,3,4,5,6,7,8,9));
$smarty->assign('tr',array('bgcolor="skyblue"','bgcolor="#0f0"'));
$smarty->display('index.tpl');
index.tpl:
{html_table loop=$data}
{html_table loop=$data cols=4 table_attr='border="0"'}
{html_table loop=$data cols=4 tr_attr=$tr}
輸出:
: