Table­Builder is a PHP class that sim­pli­fies the process of cre­ation of HTML tables with big amounts of data. This class is still in the early stages of devel­op­ment, cur­rently it can only import data from an array, but it is already usable.


A quick exam­ple of its usage:

require_once ('TableBuilder.php');

// setup a matrix of data (3x3)
$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 data

// setup the elements of column with ID h1
// to have links with values from h2
$tb->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 value
$tb->appendActionColumn('del', 'delete', 'h1');
$tb->appendActionColumn('view', 'view', 'h1');

// print out the table
echo $tb->generate();