[eluser]felixk[/eluser]
Controller:
Code:
function index()
{
$data['title'] = "Fabriken Fredag | Bildgalleri";
$this->load->library('pagination');
$config['base_url'] = site_url('/galleri/index/');
$config['total_rows'] = $this->db->count_all_results('albums');
$config['per_page'] = 4;
$config['uri_segment'] = 3;
$config['first_link'] = 'Första';
$config['last_link'] = 'Sista';
$this->pagination->initialize($config);
//DB
//Doesn't matter which one on of $data['albums'] i'm chosing.
$data['albums'] = $this->db->get('albums');
//$data['albums'] = $this->galleryModel->All($config['per_page'], $this->uri->segment(3));
$this->load->view('galleri_view', $data);
}
Viewer:
Code:
<?php if(empty($albums)): echo "Empty! :S"; ?>
<?php else: ?>
<h2>Bildgalleri!</h2>
<?php foreach($albums->result() as $row): ?>
<?php echo $row->title; ?><br />
<?php endforeach; ?>
<?php endif; ?>