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 3', 'ete', '1166702400') ); echo $this->table->generate($data);
But the function really comes on its own when you automatically generate the data, using the object returned by a database query. For...