<?php /* * @version 1.0 * @author CK * @date 22-Feb-2013 * @desc this javascript function is used to show a dynamic list has paging. * e.g: You have a list of 100 record and you fetch that through * ajax but now you want to show these records by paging * * * */ ?> <style> div.pagination { padding: 3px; margin: 3px; text-align:center; }
div.pagination a { padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #AAAADD; text-decoration: none; /* no underline */ color: #000099; }
div.pagination a:hover,div.pagination a:active { border: 1px solid #000099; color: #000; }
div.pagination span.current { padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #1A3C7D; font-weight: bold; background: none repeat scroll 0 0 #446DBD; color: #FFF; }
div.pagination span.disabled { padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #EEE; color: #DDD; } </style> <?php //====================================================== // code used in ajax php File | //====================================================== require_once("ajaxPagingManager.class.php"); //page is parameter to get current page No if(isset($_REQUEST['page'])and $_REQUEST['page']<>''){ $pageNo = $_REQUEST['page']; }else{ $pageNo=''; } if(isset($_REQUEST['extraParam'])and $_REQUEST['extraParam']<>''){ $extraParam=$extraParam; } $pageName="ajax/xyz.php"; $divid='lifeCycle';
//write this code where you are fetching the result by query //$pagename Pass the ajax file path //$div Pass the div name where result will be displayed //$extraParam if You Wish then pass extra parameter to ajax php file //$pageNo pass current Pageno
$paging_obj = new AjaxPagingManager($pageName,$divid ,$extraParam='', $pageNo);
$offsetLimit =$paging_obj->getOffset(); // this function will provide starting limit used in sql query $endLimit=$paging_obj->getStart();// this function will provide end limit used in sql query to fetch record /* * perform your query here and get result * */ //================pass the total result of query to get Paging String
$pagingStr = $paging_obj->doPaging($totalRecords); //----------print this paging String to get Paging
//=============printing paging string like this
?> <table > <tbody> <tr> <td class="pagestring"><?php print $pagingStr; ?> </td> </tr> </tbody> </table>
|