Welcome Guest, Not a member yet? Register   Sign In
Pagination problem
#1

[eluser]MrMahi[/eluser]
Hi,

I have a problem using the pagination helper and don't understand why.
The pagination links were building but when I click on them nothing happened.
In the description the pagination class looks very simple.

Model:

Code:
public function get_teams()
{
  $this->db->order_by('stars', 'desc');
  $this->db->order_by('teamname', 'asc');
  $query = $this->db->get('fifateams', 10);
  return $query->result_array();
}

Controller:

Code:
public function teams()
{
  $config['base_url']  = 'http://localhost/unendlicheliste/index.php/fifa/teams';
  $config['total_rows']  = $this->db->get('fifateams')->num_rows();
  $config['per_page']  = 10;
  $config['uri_segment'] = 3;
  $this->pagination->initialize($config);

  $data['fifateams'] = $this->fifa_model->get_teams();

  $data['title'] = lang('title_fifa_teams');
  $menu['players'] = $this->menu_model->get_playersmenu();
  
  $this->load->view('templates/header', $data);
  $this->load->view('templates/menu', $menu);
  $this->load->view('fifa/teams', $data);
  $this->load->view('templates/footer');
}

View:
Code:
<?php
echo heading(lang('h1_fifa_teams'), 1);
?>

<table class="table-bordered table-striped" cellpadding="0">
&lt;?php foreach ($fifateams as $fifateams_item): ?&gt;
<tr>
<td>&lt;?php echo $fifateams_item['teamname']; ?&gt;</td>
<td >
&lt;?php echo $fifateams_item['stars'];?&gt;
</td>
<td ><img src="http://localhost/eternallist-rl/img/teams/&lt;?php echo $fifateams_item['img_url']; ?&gt;" class="img-wappen" /></td>
</tr>
&lt;?php endforeach ?&gt;
</table>

<div class="pagination">
<ul>
<li>&lt;?php echo $this->pagination->create_links();?&gt;</li>
</ul>
</div>

Any ideas?

Kind Regards,
Jens
#2

[eluser]MrMahi[/eluser]
Ok, I solved ist.

In the Model the URI SEGMENT argument was missing:

$query = $this->db->get('fifateams', 10, $this->uri->segment(3));

Now ecreythink works fine.
#3

[eluser]zykapratama[/eluser]
on controller
Code:
$query = $this->db->query("
                SELECT
                        COUNT(*)AS jml
                FROM
                        artikel_komentar
                WHERE
                        STATUS = 0");
        foreach ($query->result() as $row) {
            $row = $row->jml;
        }
        $config['base_url'] = base_url() . 'index.php/admin/komentar/inbox/' . $id . '/';
        $config['total_rows'] = $row;
        $config['per_page'] = '10';
        $config['uri_segment'] = 4;
        $config['first_link'] = 'Awal';
        $config['last_link'] = 'Akhir';
        $config['next_link'] = 'Selanjutnya';
        $config['prev_link'] = 'Sebelumnya';
        $this->pagination->initialize($config);
        $data['komentar'] = $this->MKomentar->getKomentarMasukPagination($config['per_page'], $this->uri->segment(4));

on model
Code:
function getKomentarMasukPagination($perPage, $uri) {
        $data = array();
        $this->db->select('*');
        $this->db->from('artikel_komentar');
        $this->db->where("status", 0);
        $this->db->order_by('IDKomentar', 'desc');
        $getData = $this->db->get('', $perPage, $uri);
        if ($getData->num_rows() > 0)
            return $getData->result_array();
        else
            return null;
    }




Theme © iAndrew 2016 - Forum software by © MyBB