Making HTML tables the easy way—the Table class

Another useful library CI offers is the HTML Table class. You can see the details at the online user guide http://codeigniter.com/user_guide/libraries/table.html. But we are going to see some of their uses here. For example, if you spend a lot of time writing things such as:

echo "<tr><td>$value1</td><td>$value2</td></tr>";

CI's Table class allows you to auto-generate HTML tables. Let's display details of some of the tests we've run. You start off by loading the class, as always. Then you can specify the table data as an array, like this:

$this->load->library('table'); $data = array( array('name', 'type', 'time'), array('test 1', 'ping', '1166627335'), array('test 2', 'ping', '1166627335'), array('test ...

Get CodeIgniter 1.7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.