[eluser]pojz[/eluser]
can you help me solve this error of mine because I cannot paginate my database table. I am using 2 different tables for it, they are studentdata and course.
here is my code for the model:
<?php
class Form_model extends Model
{
function Form_model()
{
parent::Model();
}
function list_participants()
{
$sql = "SELEct course.CourseName,studentdata.LastName, studentdata.StudID, studentdata.FirstName
from course,studentdata";
$query=$this->db->query($sql);
return $query;
}
}
here is my controller:
class System extends Controller {
function System () {
parent::Controller();
$this->load->helper('url');
$this->load->database();
}
function index() {
//load pagination class
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/system/index/';
$config['total_rows'] = $this->db->count_all('studentdata');
$config['per_page'] = '5';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
//load the model and get results
$this->load->model('form_model');
$data['results'] = $this->form_model->list_participants($config['per_page'],$this->uri->segment(3));
// load the HTML Table Class
$this->load->library('table');
$this->table->set_heading('ID', 'Course', 'First Name', 'Last Name');
// load the view
$this->load->view('results', $data);
}
}
and lastly my view:
<?php echo $this->table->generate($results); ?>
<?php echo $this->pagination->create_links(); ?>
I know how to work it in a single table database but when I tried using multiple tables I cannot get to work my pagination.
I hope you can help me with this, thanks in advance.