html_table函数 登录

html_table函数

html_table函数:

自定义函数 html_table 将数组中的数据填充到 HTML 表格中. cols 属性决定表格有多少列. 

table_attr , tr_attr 和 td_attr 属性决定表格中 tr 和 td 标签的一些附加属性. 

如果 tr_attr 和 td_attr 属性值为数组,将轮流使用其中的值. 

如果指定了 trailpad 属性,将在表尾最后一行附加一些数据.

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}

输出:

:微信图片_20180313123801.png

下一节
<?php echo "html_table函数";
提交 重置代码
章节 评论 笔记 课件
  • 取消 回复 发送
  • 取消 发布笔记 发送