[eluser]ralf0909[/eluser]
i have a problem with table library, i want to show the table with all the data of the user table but something is wrong with me:
this is the model:
Code:
class User_model extends CI_Model {
function get_users()
{
$query = $this->db->get('user');
return $query->result();
}
}
this is the controller:
Code:
class Users extends CI_Controller {
function index()
{
$data = array();
$this->load->library('table');
$this->load->model('user_model');
if( $query = $this->user_model->get_users() )
{
$data['users'] = $query;
}
$this->load->view('user_view', $data);
}
and
Code:
<?php echo $this->table->generate($data); ?>
inside the view, it doesn't work, what's the error???
the only way to get table work is to put this inside the controller:
Code:
$this->load->library('table');
$query = $this->db->query("SELECT * FROM user");
echo $this->table->generate($query);
but then i can't move the table where i want on the page