Welcome Guest, Not a member yet? Register   Sign In
Pagination doesnt show "Last" link
#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.


Messages In This Thread
Pagination doesnt show "Last" link - by El Forum - 09-02-2008, 02:42 PM
Pagination doesnt show "Last" link - by El Forum - 09-02-2008, 06:17 PM
Pagination doesnt show "Last" link - by El Forum - 09-03-2008, 12:01 AM
Pagination doesnt show "Last" link - by El Forum - 09-03-2008, 04:03 PM
Pagination doesnt show "Last" link - by El Forum - 09-04-2008, 09:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB