Download


Current version: 1.0d1 (01-Aug-2005)

About

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:

1: require_once ('TableBuilder.php');
2:
3:
// setup a matrix of data (3x3)
4:
$data = array(array('a', 'b', 'c'),
5: array(
'd', 'e', 'f'),
6: array(
'g', 'h', 'i'))
7:
8:
$tb = new TableBuilder();
9:
10:
// setup the header for the table
11: // array(columnID => columnName...)
12:
$tb->setHeader(array('h1' => 'Header1',
13:
'h2' => 'Header2',
14:
'h3' => 'Header3'));
15:
16:
// load the data
17:
$tb->loadFromArray($data);
18:
19:
// setup the elements of column with ID h1
20: // to have links with values from h2
21:
$tb->setLinkColumn('h1', 'h2');
22:
23:
// it is possible to set the visibility of a column
24: // default is true, so this operation has no effect
25:
$tb->setVisible('h1', true);
26:
27:
// add an extra column with a command and a link
28: // to a column value
29:
$tb->appendActionColumn('del', 'delete', 'h1');
30:
$tb->appendActionColumn('view', 'view', 'h1');
31:
32:
// print out the table
33:
echo $tb->generate();