• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination doesnt show "Last" link

#1
[eluser]furyan[/eluser]
Hi,

My pagination works correct except the "last" link doesnt show up.
I have 5 rows that I fetch from the database so I set up my
$config['total_rows'] to the value of 5 via a function.

$config['per_page'] = 2;
$config['num_links'] = 2;

If I change the num_links value to 1 it displays the "last" link.
Can anyone explain why?

#2
[eluser]anggie[/eluser]
You have the same problem with me...
I have asked too but no answer.
Something more terrible happen when you set per_page to 2...
try that...and you will get an even page link (not the display) only...

#3
[eluser]Sumon[/eluser]
This is my custom pagination. you may try it.
Here is my controller code
Code:
$this->load->model("asknanny_model");//my model

$PerPageRecord=5;
$TotalRecord=$this->asknanny_model->TotalQuestion();//echo $TotalRecord."<br>";
$TotalListing=ceil($TotalRecord/$PerPageRecord);

if($CurListing==0)
{
  $CurListing=1;
  $RecordStart=0;
  $RecordEnd=$PerPageRecord-1;
}
else
{
  $RecordStart=( ($CurListing-1)*$PerPageRecord );    //Index no 40= Record no 41. though start from 0.
  $RecordEnd=$RecordStart+$PerPageRecord-1;
}
if($RecordEnd>$TotalRecord)
  $RecordEnd=$TotalRecord-1;
$Limit="LIMIT $RecordStart, $PerPageRecord";
if($RecordStart+1>$TotalRecord)    $DisplayStartVal=$TotalRecord;
elseif($TotalRecord>0) $DisplayStartVal=$RecordStart+1; else $DisplayStartVal=0;

if($RecordEnd+1>$TotalRecord)    $DisplayEndVal=$TotalRecord;
elseif($TotalRecord>0) $DisplayEndVal=$RecordEnd+1; else $DisplayEndVal=0;

$Data['TotalRecord']=$TotalRecord;
$Data['DisplayStartVal']=$DisplayStartVal;
$Data['DisplayEndVal']=$DisplayEndVal;
$Data['CurListing']=$CurListing;
$Data['TotalListing']=$TotalListing;
$Data['Limit']=$Limit;
$Data['CurPageRecords'] = $this->asknanny_model->RecordsForCurPage($Limit);

Here is the view (only pagination link and record portion)
Code:
Displaying &lt;?=$DisplayStartVal?&gt;-&lt;?=$DisplayEndVal?&gt;&nbsp;out of&nbsp;&lt;?=$TotalRecord?&gt;(Page&lt;? if($TotalRecord>0) echo $CurListing; else echo "0";?&gt;)

Page List : <b>
&lt;?php
    for($Listing=1;$Listing<=$TotalListing;$Listing++)
    if($Listing==$CurListing)
        echo "<b>".$Listing."</b>&nbsp;";
    else
    {
?&gt;
      <a href="&lt;?=base_url()?&gt;asknanny/AskQuestion/&lt;?=$Listing?&gt;">&lt;?=$Listing?&gt;</a>
   &lt;?    }    ?&gt;
    </b>

Hope it help you.

#4
[eluser]furyan[/eluser]
Ahh thank you, ill be sure to test it out in the near future.

I guess it just doesnt show 'Last' link because I can see alrdy the last page, wich is digit 3 in my case.
But I think it would still be handy to show the 'Last' link even though you can see a link to the last page.

#5
[eluser]Sumon[/eluser]
Okay for that change your view by

Code:
Displaying &lt;?=$DisplayStartVal?&gt;-&lt;?=$DisplayEndVal?&gt;&nbsp;out of&nbsp;&lt;?=$TotalRecord?&gt;(Page&lt;? if($TotalRecord>0) echo $CurListing; else echo "0";?&gt;)

Page List : <b>
&lt;?php
    for($Listing=1;$Listing<=$TotalListing;$Listing++)
    if($Listing==$CurListing)
    {
        if($TotalListing==$Listing) echo "Last";
        else if($Listing==1)echo "First";
        else echo $Listing;
    }
    else
    {
?&gt;
      <a href="&lt;?=base_url()?&gt;asknanny/AskQuestion/&lt;?=$Listing?&gt;">&lt;? if($TotalListing==$Listing) echo "Last"; else if($Listing==1)echo "First";else echo $Listing;?&gt;</a>
&lt;?  }    ?&gt;
    </b>


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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