Welcome Guest, Not a member yet? Register   Sign In
Can't display data generated by table library
#1

[eluser]qpixo[/eluser]
Hi all,

I'm new and trying to display some data using pagination and table library. For some reason, I can not see table generate data but only see pagination while display in browser. Does anyone can help me?

However, it will display if I hard code in View like that and remove table library in Controller:
Code:
<?php
foreach ($tabFilm as $item) {
$item->actors;
$item->title;
}
?>


Here code example:
Model:

Code:
public function getData($limit, $offset) {
        
        $this->db->select('title, actors, category, price');
        $query = $this->db->get('film_list', $limit, $offset);
        
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $item) {
                $data[] = $item;
            }            
            return $data;
        }

Controller:
Code:
public function index() {
        // Load pagination class
        $this->load->library('pagination');
        
        // Load table
        $this->load->library('table');
        
        // Init pagination
        $config['base_url'] = 'http://localhost:8888/ci/test/index.php/form_controller/index/';
        $config['total_rows'] = $this->db->count_all('film_list');
        $config['num_links'] = 5;
        $config['per_page'] = 10;
        
        $this->pagination->initialize($config);
        
        //Load form model
        $this->load->model('form_model');
        
        // Call the function getData
        $data['tabFilm'] = $this->form_model->getData($config['per_page'], $this->uri->segment(3));
        
        
        // Load form view
        $this->load->view('form_view', $data);
    }

View:

Code:
<!DOCTYPE html>

&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Form&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
    <h2>Top Movies</h2>

            
    &lt;?php echo $this->table->generate($tabFilm); ?&gt;
    &lt;?php echo $this->pagination->create_links(); ?&gt;
    
&lt;/body&gt;
&lt;/html&gt;




Theme © iAndrew 2016 - Forum software by © MyBB