Table
Table
- Version: 1.0
- Author: Raymond Kolbe <rkolbe at gmail dot com>
- License: GPLv3
- Download Now
Table is a view helper written in PHP for PHP enabled web sites that want to produce W3C compliant HTML tables using PHP.
Features to come:
- Add convenience methods for mass adding of data
Usage Example
To produce a simple table such as:
<table summary="A sample table used to show what Table view helper can do.">
<caption>My sample table</caption>
<thead>
<tr>
<th>
Name
</th>
<th>
Age
</th>
<th>
Sex
</th>
<tr>
</thead>
<tbody>
<tr>
<td>Bob</td>
<td>35</td>
<td>Male</td>
</tr>
<tr>
<td>Mary</td>
<td>92</td>
<td>Female</td>
</tr>
<tr>
<td>Chairman P. Meow</td>
<td>2</td>
<td>Male</td>
</tr>
</tbody>
<table>
All we do is:
<?php
require 'Table.php';
$table = new Table();
$table->addAttribute('summary', 'A sample table used to show what Table view helper can do.');
$table->addCaption('My sample table');
$row1 = $table->addGroup('thead')->addRow();
$row1->addHeadingCell('Name');
$row1->addHeadingCell('Age');
$row1->addHeadingCell('Sex');
$tbody->addGroup('tbody');
$row2 = $tbody->addRow();
$row2->addDataCell('Bob');
$row2->addDataCell('35');
$row2->addDataCell('Male');
$row3 = $tbody->addRow();
$row3->addDataCell('Mary');
$row3->addDataCell('92');
$row3->addDataCell('Female');
$row4 = $tbody->addRow();
$row4->addDataCell('Chairman P. Meow');
$row4->addDataCell('2');
$row4->addDataCell('Male');
print $table->display();