mám niečo takéto
Kód: Vybrať všetko
<?php echo anchor('poradie','poradie','title="" '); vypíše to link s odkazom na poradie
v routes.php mám
$route['poradie/(:num)'] = 'page/poradie_controler/$1';
a v samotnom poradie_contoler
function index(){
$this->load->model('poradie_model');
$this->load->library('pagination');
$config['base_url'] = base_url().'poradie' ;
$config['total_rows'] = $this->poradie_model->pocet_riadkov();
$config['per_page'] = 1;
$config['uri_segment'] = 2;
if ( ($data['poradie'] = $this->poradie_model->vypis($config['per_page'],$config['uri_segment'] )) ) {
$this->pagination->initialize($config);
$this->load->library('table');
$tmpl = array ( 'table_open' => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' ); $this->table->set_template($tmpl);
$this->load->view('page/poradie_view',$data);
}else{
redirect('home');
}
}
ešte view
Kód: Vybrať všetko
<?php $this->load->view('inc/header'); ?>
<!--Hlavička Tabulky#############################################-->
<?php $i=1; $this->table->set_heading('#', 'Meno'); foreach ($poradie->result() as $key ) : ?>
<!--#############################################-->
<!--Obsah Tabulky#############################################-->
<?php $this->table->add_row($i,anchor('user/'.$key->id,$key->meno) ); $i=$i+1; ?>
<!--#############################################-->
<!--Koniec Tabulky#############################################-->
<?php endforeach; echo $this->table->generate(); echo $this->pagination->create_links(); ?>
<!--#############################################-->
<?php $this->load->view('inc/footer'); ?>
Kód: Vybrať všetko
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Poradie_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
//***********************************************
function vypis($limit,$ofset) { // Vypiše všetkych user pod bodov
$succes = $this->db->order_by('body desc')
->select('id,meno')
->get('uzivatel',$limit,$ofset);
if ( $succes->num_rows() > 0 ) { return $succes; } else { return false; }
}
function pocet_riadkov(){ // Zisti pocet user kvlo strankovaniu
$succes = $this->db->count_all_results('uzivatel')
return $succes;
}
//***********************************************
}