[eluser]Unknown[/eluser]
I am trying ot use the table class to display a table of data I have retrieved from my database. My model method looks like this:
Code:
function index() {
$data = array();
$this->load->library('pagination');
$this->load->library('table');
$config['base_url'] = 'http://localhost:8888/ci/index.php/site/index';
$config['total_rows'] = $this->db->get('data')->num_rows();
$config['per_page'] = 5;
$config['num_links'] = 20;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
if($query = $this->site_model->getRecords('data',$config['per_page'],$this->uri->segment(3))) {
$data['records'] = $query;
}
$this->load->view("options_view",$data);
}
My view (options_view.php) code looks like this:
Code:
if(isset($records)) {
echo $this->table->generate($records);
}
else {
echo "No Rows Returned!!!";
}
echo $this->pagination->create_links();
I can use a foreach loop to loop through the $records variable and display the results but would very much like to make use of the awesome table helper class. any ides on where I am going wrong here?
Mike.