TableBuilder is a PHP class that simplifies the process of creation of HTML tables with big amounts of data. This class is still in the early stages of development, currently it can only import data from an array, but it is already usable.
Example
A quick example of its usage:
require_once (‘TableBuilder.php’);
// setup a matrix of data (3×3)
data = array(array(‘a’, ‘b’, ‘c’),
array(‘d’, ‘e’, ‘f’),
array(‘g’, ‘h’, ‘i’))tb = new TableBuilder();
// setup the header for the table
// array(columnID => columnName…)
tb->setHeader(array(‘h1’ => ‘Header1’,
‘h2’ => ‘Header2’,
‘h3’ => ‘Header3’));
// load the datatb->loadFromArray(data);
// setup the elements of column with ID h1
// to have links with values from h2tb->setLinkColumn(‘h1’, ‘h2’);
// it is possible to set the visibility of a column
// default is true, so this operation has no effect
tb->setVisible(‘h1’, true);
// add an extra column with a command and a link
// to a column valuetb->appendActionColumn(‘del’, ‘delete’, ‘h1’);
tb->appendActionColumn(‘view’, ‘view’, ‘h1’);
// print out the table
echotb->generate();