Paging Library

The main objective of this library is to provide a easy to use function to apply paging for HTML based reports. With the functions provided in this library you will be able to apply paging to most of the reports you generate in the system. But there are special cases where you can not use this library. We encourage you to use this library rather than using your own code to ensure that every paging interface will have a consistent look and feel so that the users will be more comfortable with the system.

  • $query- SQL query that developer needs to have paginated result.
  • $rpp- Records per page.
  • $headers- Report headers (If developer needs to print report using paging library).
  • $extra_opt- This is an array. Developer can set return flag and post flag using this option.


  • return flag- If this is 'true', function will return only an array containing paginated results with navigation links. Otherwise function will print the paginated report for the developer.
  • post flag- If this is 'true', then the library will handle complex queries (queries with post values) and do the requested operation (print the report or return the result array).

Example usage - with simple queries

include_once ("");
$query='SELECT * from person_uuid';
$headers=array('ID','Full Name','Family Name','L10N Name','Custom Name');
//following function will print paginated report for the developer.

Example usage - queries with POST values.

include_once ("");
$query='SELECT * from person_uuid WHERE full_name="'.$_POST['John'].'"';
$headers=array('ID','Full Name','Family Name','L10N Name','Custom Name');
//following function will print paginated report for the developer.

Unusable places

  • If the sql query contains UNION key word it is not possible to use this library for paging.

Reason for this is the paging library use PageExecute(); function in ADODB to fetch pages. The PageExecute(); function use _adodb_getcount() function to count the number of records in a query. This _adodb_getcount() function doesn't support queries with UNION key word for some database drivers. So In the future we would modified the paging library to support UNION key word as well by using some other mechanism to fetch pages.

QR Code
QR Code swat:paging_library (generated for current page)