i.e. first page link, previous page link, page numbers link, next page link, last page link.
You need to add javascript function called paginate(page_no) which takes page no as the argument & in turns do AJAX call for fetching the next records.
Argument list for pagination function:
- $current_page: current page number
- $cnt: total records
- $limit: No of records to be displayed
function pagination($current_page,$cnt,$limit){
$last_page = ceil($cnt/$limit);
$str = "";
$first_pg = "";
$prev_pg = "";
$next = "";
$last = "";
if($last_page == 1){
$first_pg = " << ";
$prev_pg = " < ";
}else{
if($current_page > 1){
$first_pg = "<a href=\"javascript:void(0)\" onClick=\"paginate(1)\"> << </a>";
$prev_pg = "<a href=\"javascript:void(0)\" onClick=\"paginate($current_page-1)\"> < </a>";
}
for($i=1;$i<=$last_page;$i++){
if($i == $current_page)
$str .= $i." | ";
else
$str .= "<a href=\"javascript:void(0)\" onClick=\"paginate($i)\"><u>".$i."</u></a> | ";
}
$str = substr($str,0,strlen($str)-2);
if($current_page != $last_page){
$next = "<a href=\"javascript:void(0)\" onClick=\"paginate($current_page+1)\"> > </a>";
$last = "<a href=\"javascript:void(0)\" onClick=\"paginate($last_page)\"> >> </a>";
}
if($current_page == $last_page){
$next = " > ";
$last = " >> ";
}
}
$page_string = $first_pg.$prev_pg.$str.$next.$last;
return $page_string;
}