• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codeigniter's pagination offset not working

#1
[eluser]Blazetama[/eluser]
Hello All,

I have asked this question on stackoverflow, please see this link :

http://stackoverflow.com/questions/16376...1#16376402

Sometimes, i dont get good answer in SO when im talking about CI, so i come here.

Any help will be appreciated, thanks Big Grin

#2
[eluser]TheFuzzy0ne[/eluser]
Are the pagination links being generated as you'd expect? Please paste a few examples of the URLs it's generating.

Does $result['num_rows'] contain a valid value?

What do you mean when you say "the $offset value is true". It should be an integer.

#3
[eluser]Blazetama[/eluser]
[quote author="TheFuzzy0ne" date="1367687740"]Are the pagination links being generated as you'd expect? Please paste a few examples of the URLs it's generating.

Does $result['num_rows'] contain a valid value?

What do you mean when you say "the $offset value is true". It should be an integer.[/quote]

Thanks for your response Big Grin
Yes, the pagination is working as expected (except for the offset).

The example of url when offset is 0 (default value, i check the $offset value by echoing it) :

http://localhost/ci_gabdb/index.php/backend_umat/index -> the index start from 1

When $offset is 10 :

http://localhost/ci_gabdb/index.php/backend_umat/index/10 -> the $offset value is true because the limit is 10 and this is the 2nd page in pagination, but the index start from 1 again.

I tried to echo $result['num_rows'] , it returns a valid (integer) value.

Do you have any idea whats going on here? Thanks

#4
[eluser]rana[/eluser]
[quote author="Blazetama" date="1367762970"]but the index start from 1 again.
[/quote]

Here, by 'index' , did you mean the index of the list you are showing? If so, it is generating ok, you are understanding wrong. To show list number, you will have to do a little tweak like:

for($i=0;$i<count($result);$i++){
$row = $result[$i];
echo "data serial#".($offset+$i)." : ".$row->kelas_id;
}

If your problem in something else, please make it clear. Also, Please share your view code as well.

#5
[eluser]Blazetama[/eluser]
First, i would like to thanks to TheFuzzyOne and Rana who helped me kindly Big Grin

And, i want to say sorry because i made a "stupid" mistake which took me for hours to realize. The pagination is working perfectly, i just forget to use the
Code:
$offset
:

Before -> i use
Code:
$no = 1
:

Code:
$no = 1;
  foreach($data_umat as $list_temp)
  {
   $this->table->add_row(
    $no++,
    $list_temp->nama,
    $list_temp->kelas,
    $list_temp->alamat,
    $list_temp->tanggal_lahir,
    $list_temp->sekolah,
    $list_temp->no_tlpn,
    $list_temp->keterangan
   );
  }

Now (Working) :

Code:
foreach($data_umat as $list_temp)
  {
   $this->table->add_row(
    ++$offset,
    $list_temp->nama,
    $list_temp->kelas,
    $list_temp->alamat,
    $list_temp->tanggal_lahir,
    $list_temp->sekolah,
    $list_temp->no_tlpn,
    $list_temp->keterangan
   );
  }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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