Welcome Guest, Not a member yet? Register   Sign In
HTML Table class not working for me!
#1

[eluser]Unknown[/eluser]
Hello:

I am new to CI and PHP.. I was able to get a database connection and can echo data. I then tried to use the HTML Table class and am receiving the following error:

A PHP Error was encountered
Severity: Notice

Message: Undefined property: CI_Loader::$table

Filename: views/heartbeat_view.php

Line Number: 72


Fatal error: Call to a member function generate() on a non-object in /usr/local/apache2/htdocs/system/application/views/heartbeat_view.php on line 72

Here is the code:

<h1>Welcome to the RMLS Heartbeat View page!</h1>

&lt;?php
$NOCC_DB = $this->load->database('nocc', TRUE);

$result = $NOCC_DB->query('select * from heartbeat_table');
if ($result->num_rows() > 0)
{
foreach ($result->result() as $row)
{
echo $row->MODIFYING_DB;
echo "\t";
echo $row->MODIFIED_DATETIME;
echo "<br>";
}
}

$this->load->library('table');
$data = array(
array('Name', 'Color', 'Size'),
array('Fred', 'Blue', 'Small'),
array('Mary', 'Red', 'Large'),
array('John', 'Green', 'Medium')
);

echo $this->table->generate($data);

?&gt;

I grabbed the example right from the CI User Guide just to make sure the mechanics were working correctly. It too produces that same error. I know the classes are loading correctly because the database and OCI libraries are working.

Can someone explain how to determine why this table class is not working?

Thanks!

Paul
#2

[eluser]canicasio[/eluser]
In autoload.php you have to load the table class:

$autoload['libraries'] = array('table');
#3

[eluser]CleverMind[/eluser]
You have to load 'table' library in constructor of the controller.




Theme © iAndrew 2016 - Forum software by © MyBB