Table helper is very useful and powerful helper. you can make the table from database automatically as just input some format to table array.
$FE->loadHelper("table");
first inside array is tr-tag and inside the tr-array is td-array
"table"=> array(
array( // this array is "tr"
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
),
array(
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
)
);
"table"=> array(
array( // this array is "tr"
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
),
array(
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
)
);
"table"=> array(
array( // this array is "tr"
array("cdata"=>array(
array("div"=>array("id"=>"bbb","cdata"=>"1111")),
array("cdata"=>" "),
array("div"=>array("style"=>"clear:both;")),
array("input"=>array("id"=>"aaa","value"=>"2222")),
)","id"=>"aa","class"=>"asdfas"),
),
array(
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
)
);
If the tr-array's element is not array type,it will be attributes.
"table"=> array(
array( // this array is "tr"
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
"id"=>"table1","class"=>"tbclass",
),
array(
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
)
);
If the tr-array's element is not array type,it will be attributes.
"table"=> array(
"header"=>array(
array(
array("cdata"=>"Name"),
"id"=>"1",
),
"id"=>"1", // attribute of thead
),
array( // this array is "tr"
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
"id"=>"table1","class"=>"tbclass",
),
array(
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
)
);
$table=array(
"header"=>array(
array(
array("cdata"=>"Name"),
array("cdata"=>"Address"),
array("cdata"=>"Calendar"),
array("cdata"=>"Profile"),
"id"=>"1",
),
"id"=>"1",
),
array(
array("cdata"=>"<input type='text' value='text'/>","id"=>"aa","class"=>"asdfas"),
array("cdata"=>"asdfsdfasdf","id"=>"aa","class"=>"asdfas"),
array("cdata"=>"asdfasddddddf","id"=>"aa","class"=>"asdfas"),
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
"id"=>"1",
),
array(
array("cdata"=>array("input"=>array("id"=>"aaa","value"=>"fff")),"id"=>"aa","class"=>"asdfas"),
array("cdata"=>array(
array("div"=>array("id"=>"bbb","cdata"=>"1111")),
array("cdata"=>" "),
array("div"=>array("style"=>"clear:both;")),
array("input"=>array("id"=>"aaa","value"=>"2222")),
),
"id"=>"aa","class"=>"asdfas"),
array("cdata"=>array(
array("a"=>array("href"=>"bbb","cdata"=>"link")),
array("cdata"=>" "),
array("input"=>array("id"=>"aaa","value"=>"2222")),
),"id"=>"aa","class"=>"asdfas"),
array("cdata"=>"asdfabbbbbb","id"=>"aa","class"=>"asdfas"),
"table"=>array(
array(
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
),
array(
array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
),
),
"id"=>"2",
),
"class"=>"asddfas",
"id"=>"asdfasdf",
"style"=>"width:800px;",
);
$Frontend->members is from database which is created by model or controller.
$table=$Frontend->Table->genTable($format,$Frontend->members);
echo $Frontend->Table->draw($table); // display the table
you can generate the table from database very simply as making the format of table such as header and each columns.
$format=array(
"header"=>array(
array(
array("cdata"=>"id"),
array("cdata"=>"NickName"),
array("cdata"=>"email"),
array("cdata"=>"level"),
),
),
"columns"=>array('$member_id',
'$member_nickname',
'$member_email',
'<input type=\"text\" value=\"$member_level_id\">'),
"class"=>"table",
"id"=>"asdfasdf",
"style"=>"width:800px;",
);
$table=$Frontend->Table->genTable($format,$Frontend->members);
echo $Frontend->Table->draw($table);