Creating Following Pagination format
Example :-
$strPosition=$_REQUEST['startPostion']; //Record Start Position
if(isset($strPosition) && $strPosition>=1){
$start=$strPosition;
}else{
$start=0;
}
$display=15; //No. of record dispaly onl single page or one Page
$rsCount; //No. of record fetch from recordset (database table)
$pages=ceil($rsCount/$display); //Calculate pages will display or get from database table
<div align="left" style="width:500px; border:#666666 solid 1px; display:block;">
<!-- Display Previous Page Button(Link) -->
<div align="left" style="float:left">
<?php
// echo $currentPage;
if($pages>1){
$currentPage=($start/$display)+1; //Current Page No. on which page is have
$stPageNo=$currentPage-4; //Set Start Page no for page range
$endPageNo=(($currentPage+5)<$pages)? $currentPage+5 : $pages; //Set End Page No for page range
if($currentPage>=1){
echo '<a href="'.$_SERVER["PHP_SELF"].'?startPostion='.($start-$display).'">
<span style="color:#FF9933; font-family:Arial, Helvetica, sans-serif; font-size:14px">Previous Page</span>
</a>';
}
}
?>
</div>
Ex:-
<!-- List of Page No in Block Format-->
<div align="left" style="float:left; padding-left:5px;">
<?php
for($i=$stPageNo;$i<=$endPageNo;$i++){
if($i>0){
if($i==$currentPage){
echo'<span title="Current Page">'.$i.'</span>';
}else{
echo '<a title="page '.$i.'" href="'.$_SERVER['PHP_SELF'].'?startPostion='.($display*($i-1)).'" class="no-underline">
<span style="color:#FF9933; font-family:Arial, Helvetica, sans-serif; font-size:14px; display:block; border:#CCCCCC solid 1px; width:15px; text-align:center;">'.$i.' '.'</span></a>';
}
}
}
?>
</div>
Ex:-
<!-- Display Next Page Button(Link) -->
<div align="left" style="float:right">
<?php
if($pages>1){
if($currentPage!=$pages){
echo '<a href="'.$_SERVER["PHP_SELF"].'?startPostion='.($start+$display).'"><span style="color:#FF9933; font-family:Arial, Helvetica, sans-serif; font-size:14px">Next Page</span></a>';
}
}
?>
</div>
Ex:-
</div>
Out Put:-
This comment has been removed by a blog administrator.
ReplyDelete