[eluser]ThatsJustMe[/eluser]
Hello,
So basically I have a helper and it's code is -
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if (!function_exists('records'))
{
function records()
{
$ci = get_instance();
$ci->db->order_by("date", "desc");
$ci->db->limit(20);
$query = $ci->db->join('records', 'users.id=records.user_id')->get('users');
$data =array();
foreach($query->result_array() as $orders)
{
$data[] = $orders;
}
return $data;
}
}
?>
Now I need to add a pagination for it, so there is only 5 rows per page. I tried to add pagination library and echoed it out, but it gives me 3 pages, which doesn't work. Code -
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if (!function_exists('records'))
{
function records()
{
$ci = get_instance();
$ci->db->order_by("date", "desc");
$ci->db->limit(20);
$query = $ci->db->join('records', 'users.id=records.user_id')->get('users');
$data =array();
foreach($query->result_array() as $orders)
{
$data[] = $orders;
}
$ci->load->library('pagination');
$config['base_url'] = 'http://localhost/savieno/records/';
$config['total_rows'] = 20;
$config['per_page'] = 5;
$ci->pagination->initialize($config);
echo $ci->pagination->create_links();
return $data;
}
}
?>
Any suggestions?