[eluser]Johan Michel[/eluser]
I solved most of the issues, the files contain quite a lot of errors. Here is a small improved version for people who are going to use it in the future:
Code:
<? class My_data_page extends Controller{
function My_data_page(){
parent::Controller();
$this->load->library('table');
$this->load->helper('html');
$this->load->library('Ajax_pagination');
}
function index(){
$data['makeColumns'] = $this->makeColumns();
$data['getTotalData'] = $this->getTotalData();
$data['perPage'] = $this->perPage();
$this->load->view('my_data_page', $data);
}
//Pull 'name' field records from table 'contact'
function getData(){
$page = $this->input->post('page'); //Look at $config['postVar']
if(!$page):
$offset = 0;
else:
$offset = $page;
endif;
$sql = "SELECT * FROM foo LIMIT ".$offset.", ".$this->perPage();
$q = $this->db->query($sql);
return $q->result();
}
function getTotalData(){
$sql = "SELECT * FROM foo";
$q = $this->db->query($sql);
return $q->num_rows();
}
function perPage(){
return 10; //define total records per page
}
//Generate table from array
function makeColumns(){
$foo = $this->getData();
foreach($books as $row):
$data[] = $row->isbn;
$data[] = $row->title;
$data[] = $row->link;
endforeach;
return $this->table->make_columns($data, 6);
}
}
?>