Problem in Pagination

Hey guys i am doing pagination and i am unable to resolve this thing. I am getting the value of $this->uri->segment(4) for my offset but it returns nothing.

class Users extends Controller {

function Users(){



function users_view(){

/// set page title
$this->data['title'] = 'View Users Records ';

/******Paginating Records********/
$config['base_url'] =base_url().$this->config->item('index_page').'/'.'users/users_view';
$config['total_rows'] = $rows;
$config['per_page'] = '5';
$config['uri_segment'] = 4;
$config['num_links'] = 4;
$config['first_link'] = '«';
$config['last_link'] = '»';
$config['next_link'] = '>';
$config['prev_link'] = '<';

$user_id = $_SESSION['user_id'];
$data['alluserList'] = $this->usermodel->get_all_user($config['per_page'],$this->uri->segment(4),$user_id); //

A Database Error Occurred

SELECT * from tms_user where userId <> 1 and deleted='0' order by username LIMIT 5,

Thanx in advance.....

[eluser]Thorpe Obazee[/eluser]
[quote author="zombica" date="1246014496"]
$config['base_url'] =base_url().$this->config->item('index_page').'/'.'users/users_view'

it could be easier to just use. site_url('users/users_view');

Anyway, try $this->uri->segment(3) here

$data[‘alluserList’] = $this->usermodel->get_all_user($config[‘per_page’],$this->uri->segment(4),$user_id);

Thanx... Buddy you there again for resolving my problem. Hey man this doesn't affect any thing same DB error showing nothing for offset.

[eluser]Thorpe Obazee[/eluser]
$config[‘uri_segment’] = 4;

Is there any reason why you're using segment 4? It seems that the segment should be 3. Are you using routing?

Can you show get_all_user() from the model?

Here it goes....

//Get All users data
function get_all_user($num,$offset,$user_id)
$query = $this->db->query("SELECT * from tms_user where userId <> $user_id and deleted='0' order by username LIMIT ".$num.",".$offset." ");
return $result;

No i can use $this->uri->segment(3) .. i am not using any kind of routing. I have done this by both 3 and 4. It doesn't affects.

[eluser]Thorpe Obazee[/eluser]
Try using the AR. I assume the problem occurs on the first page only. Nothing is preventing the ',' comma from getting in your query which causes the error.

$this->db->where(array('userId' <> =>$user_id, 'deleted' => 0));
$this->db->limit($num, $offset);
$query = $this->db->get('tms_user');

if ($query->num_rows() > 0)
    return $query->result();
return FALSE;

Yes problem is with only the first page it does not comes once we are in some inner page.

Giving parse error on this line....
$this->db->where(array('userId' <> =>$user_id, 'deleted' => 0));

Thanx it resolve. Thanx buddy a lot.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.