技術や物事のかきとめ(旧データ)

はてなダイアリーからの移行です。もともとかつて「はてなグループ」で公開していた内容を移動しました。

html_table関数の注意

<th>タグにタイトル名などを入れたい場合は、使用するのが難しい。
→配列の中にタイトル名を入れる必要がありそう。

追記

trの中身を配列にセットして{html_table}関数を使用している例
http://sunset.freespace.jp/Smarty/SmartyManual_2-6-6J_html/language.function.html.table.html

<?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="#eeeeee"','bgcolor="#dddddd"'));
$smarty->display('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}

※単純に値をテーブルとする場合は、この関数で記述した場合「1行」でテーブル定義ができる。