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

I have some problem with pagination

There are my model

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Nazione_modello extends CI_Model {

public function seleziona_nazioni($limite,$offset)
{

$query = $this->db->get('nazione',$limite,$offset);

return $query->result_array();

}

public function conta_nazioni()
{

$query = $this->db->get('nazione');

return $query->num_rows();

}

}

?>

my controller

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Sito extends CI_Controller {



public function guide()
{


$this->load->library('pagination');

$this->load->model('nazione_modello');

$offset = 0;
$config['base_url'] = 'http://localhost/codeigniter/sito/guide';
$config['total_rows'] = $this->nazione_modello->conta_nazioni();
$config['per_page'] = 5;


$this->pagination->initialize($config);


$data['tabella'] = $this->nazione_modello->seleziona_nazioni($config['per_page'],$offset);
$data['num_nazioni'] = $config['total_rows'];
//$data['config'] = $config;

$this->table->set_heading('Id_nazione', 'Nome_nazione');


$this->load->view('guide',$data);


}


}

?>

and my view

<?php


foreach($tabella as $row){

echo $row['nome_nazione'];

echo '</br></br>';

}



echo $this->pagination->create_links();

?>

All is visualized correctly but when i click the link of pagination the elements don't change?

Someone could help me please?
Reply
#2

(09-24-2015, 10:20 AM)stroppik76 Wrote: I have some problem with pagination

There are my model

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Nazione_modello extends CI_Model {

public function seleziona_nazioni($limite,$offset)
{

$query = $this->db->get('nazione',$limite,$offset);

return $query->result_array();

}

public function conta_nazioni()
{

$query = $this->db->get('nazione');

return $query->num_rows();

}

}

?>

my controller

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Sito extends CI_Controller {



public function guide()
{


$this->load->library('pagination');

$this->load->model('nazione_modello');

$offset = 0;
$config['base_url'] = 'http://localhost/codeigniter/sito/guide';
$config['total_rows'] = $this->nazione_modello->conta_nazioni();
$config['per_page'] = 5;


$this->pagination->initialize($config);


$data['tabella'] = $this->nazione_modello->seleziona_nazioni($config['per_page'],$offset);
$data['num_nazioni'] = $config['total_rows'];
//$data['config'] = $config;

$this->table->set_heading('Id_nazione', 'Nome_nazione');


$this->load->view('guide',$data);


}


}

?>

and my view

<?php


foreach($tabella as $row){

echo $row['nome_nazione'];

echo '</br></br>';

}



echo $this->pagination->create_links();

?>

All is visualized correctly but when i click the link of pagination the elements don't change?

Someone could help me please?

Parameter for method guide:

Code:
public function guide($pagine_index = 0) //default 0
{

and use that parameter:

Code:
$offset = (int) $pagine_index;

Reply




Theme © iAndrew 2016 - Forum software by © MyBB