Welcome Guest, Not a member yet? Register   Sign In
pagination, newbie to codeigniter
#1

[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:
&lt;?php echo $this->table->generate($results); ?&gt;
&lt;?php echo $this->pagination->create_links(); ?&gt;

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.
#2

[eluser]pojz[/eluser]
anyone tried using 2 tables when paginating??
#3

[eluser]pojz[/eluser]
done i just resolve it,, hehehe what a noob me
#4

[eluser]kevinprince[/eluser]
Apologies was going to post reply this morning, didnt have the energy last night.

For the record what was your resolution?
#5

[eluser]dinaco[/eluser]
hi can anyone show me a solution to show 2 tables using $this->table->generate(); ?
#6

[eluser]dinaco[/eluser]
just figured it out!

i called the first table like this $this->table->generate($results_1); then i cleared it before i called the next table using $this->table->clear(); and then i call the second table $this->table->generate($results_2);

well thats it

tks




Theme © iAndrew 2016 - Forum software by © MyBB