Location: PHPKode > scripts > Pagination Advanced > kbpaginationadvanced/kbpaginationadvanced/function.php
<?php
 
function paging($mode, &$paging_array)
{
 $paging_pgurl=$paging_array['paging_pgurl'];
 $paging_records=$paging_array['paging_records'];
 $paging_recordsperpg=$paging_array['paging_recordsperpg'];
 $paging_linksshow=$paging_array['paging_linksshow'];
 $paging_currentpg=$paging_array['paging_currentpg'];
 $paging_array['paging_navigation']="";
 
 //$paging_records=$total_records;
 //$paging_recordsperpg="20";
 $paging_pages=ceil($paging_records/$paging_recordsperpg);
 
 //$paging_linksshow="5";
 
 if($paging_pages<$paging_linksshow)
 {
 $paging_linksshow=$paging_pages;
 }
 
 if($paging_currentpg>$paging_pages)
 {
 $paging_currentpg="1";
 }
 
 $paging_recordstart=(($paging_currentpg-1)*($paging_recordsperpg))+1;
 if($paging_recordstart<1)
 {
 $paging_recordstart="1";
 }
 $paging_array['paging_recordstart']=$paging_recordstart;
 
 $paging_recordend=$paging_recordstart+$paging_recordsperpg-1;
 if($paging_recordend>$paging_records)
 {
 $paging_recordend=$paging_records;
 }
 $paging_array['paging_recordend']=$paging_recordend;
 
 $paging_from=$paging_currentpg-ceil($paging_linksshow/2);
 if($paging_from<'1')
 {
 $paging_from="1";
 }
 
 $paging_to=$paging_currentpg+ceil($paging_linksshow/2);
 if($paging_to>$paging_pages)
 {
 $paging_to=$paging_pages;
 }
 
 $paging_prevpg=$paging_currentpg-1;
 $paging_nextpg=$paging_currentpg+1;
 
 if($paging_currentpg>'1')
 {
 $paging_array['paging_navigation'].=" <a href='?paging_pgnum=1'>First</a> ";
 $paging_array['paging_navigation'].=" <a href='?paging_pgnum=$paging_prevpg'>Previous</a> ";
 }
 else
 {
 $paging_array['paging_navigation'].=" <a>First</a> ";
 $paging_array['paging_navigation'].=" <a>Previous</a> ";
 }
 
 for($i_paging=$paging_from; $i_paging<=$paging_to; $i_paging++)
 {
 if($i_paging==$paging_currentpg)
 {
 $paging_array['paging_navigation'].=" <b class='selected'>$i_paging</b> ";
 }
 else
 {
 $paging_array['paging_navigation'].=" <a href='?paging_pgnum=$i_paging'>$i_paging</a> ";
 }
 
 }
 
 if($paging_currentpg<$paging_pages)
 {
 $paging_array['paging_navigation'].=" <a href='?paging_pgnum=$paging_nextpg'>Next</a> ";
 $paging_array['paging_navigation'].=" <a href='?paging_pgnum=$paging_pages'>Last</a> ";
 }
 else
 {
 $paging_array['paging_navigation'].=" <a>Next</a> ";
 $paging_array['paging_navigation'].=" <a>Last</a> ";
 
 }
 
 $paging_recordsshowing=$paging_recordend-$paging_recordstart+1;
 $paging_array['paging_currentpg']=$paging_currentpg;
 $paging_array['paging_pages']=$paging_pages;
 $paging_array['paging_recordsshowing']=$paging_recordsshowing;
}
 
?>
Return current item: Pagination Advanced