Creating HTML Tables
You can include this library to your code file by typing the below code;
use Ness\UI\Table
Result for the code above
Required Namespace
- Ness
- UI
- Table
- UI
You can include this library to your code file by typing the below code;
use Ness\UI\Table
About HTML Table Class #top
You can create html tables easily with help of the Table class.
Methods Explained with Examples - Create a HTML Table #top
__construct
$mytable = new Ness\UI\Table();
$secondTable = new Ness\UI\Table(array("class"=>"css-table-class"));
initialize table class | ||
Return | Void | |
Parameters | $prm Array; class attributes, key as tag and value as data |
Create
$mytable = new Ness\UI\Table();
..[header]
...[rows]
.....[other.]
echo $mytable->Create();
This function is for printing table to view. Table will be shown the place you type this function. Returns complete html table as string. | ||
Return | String | |
Parameters | None |
HeaderAttributes
$mytable = new Ness\UI\Table();
$mytable->HeaderAttributes(array("class"=>"html-table-header-css", "id"=>"users"));
set attributes for table header @param array class attributes, key as tag and value as data @return void | ||
Return | Void | |
Parameters | $prm Array; Header attributes |
TableHeaders
$mytable = new Ness\UI\Table();
$mytable->TableHeaders(array("#", "ID", "Name","Surname"));
Set headers for table | ||
Return | $this | |
Parameters | $prm Array; Headers |
RowAttributes
$mytable = new Ness\UI\Table();
$mytable->TableHeaders(array("#", "ID", "Name","Surname"));
$mytable->RowAttributes(array("class"=>"table-row", "id"=>1));
set attributes for table rows | ||
Return | Void | |
Parameters | $prm Array; class attributes, key as tag and value as data |
SpecialTag
$mytable = new Ness\UI\Table();
$mytable->TableHeaders(array("#", "ID", "Name","Surname"));
$mytable->RowAttributes(array("class"=>"table-row", "id"=>1));
$mytable->SpecialTag("<item> 1 .... ")->SpecialTag("<test> A ");
Create your special tags if not available by default in Ness PHP | ||
Return | $this | |
Parameters | $prm String |
AddRow
$mytable = new Ness\UI\Table();
$mytable->HeaderAttributes();
$mytable->TableHeaders(array("#", "ID", "Name","Surname"));
$mytable->RowAttributes(array("class"=>"table-row", "id"=>1));
$mytable->AddRow(array("#"=>"1", "ID"=>"1545","Name"=>"limeberry","Surname"=>"Framework"))
->AddRow(array("#"=>"2", "ID"=>"147","Name"=>"Sinan","Surname"=>"SALIH"))
->AddRow(array("#"=>"3", "ID"=>"1241","Name"=>"Test","Surname"=>"limeberry"))
->AddRow(array("#"=>"0", "ID"=>"10","Name"=>"For example","Surname"=>"removed record"), array("class"=>"danger"));
echo $mytable->Create();
Add row to current table | ||
Return | $this | |
Parameters | $prm Array; Items as array to add $prm2 Array; Item attributes (Key for attribute and Value for option. Example;array("class"=>"danger") |
Result for the code above