- Instantiate the class: First you need to instantiate the class like this
|
$classInstant = new MaximPaginator($hostname, $server_username, $server_password, $database_name, $recordPerPage, $querySQL);
|
e.g To instantiate the class for an sql "SELECT * FROM table" with maximum of 10 record returns per page.
$paginator = new MaximPaginator("localhost", "root", "password", "myDb", 10, "SELECT * FROM table");
|
|
- Set the class variable vars: Although this step is not compulsory but it is advised to follow to avoid inconsistency. This will enable the class to retain all url ($_GETS[]) data e.g if the query depends on a url data like incase of a search, the class will still retains this data in the navigation link.
|
$vars = get_defined_vars();
$paginator->setDefinedVars($vars); |
Note if the step is taken, the first line is not to be edited. |
|
- Get Query Resource: You can get the query resource processed by the class for use in your program.
|
$queryRes = $paginator->getQueryResource(); |
|
- Customise Navigation Links: You can customised the navigation link word which are defaulted as "Next, Previous, Last, First". You can change those defaulted link word by your own wordsor graphics(images).
|
$paginator->customiseNavigationLink($nextLinkCustom, $previousLinkCustom, $firstLinkCustom, $lastLinkCustom); |
|
- Display Navigation Links: Then, you display the navigation link at a point in your webpage.
|
$paginator->displayNavigator(); |
|
- Other useful functions:
|
- getCurrentPage(): This function will return the current page number.
|
- getRecordPerPage(): This function will return the number of record per page set in the class constructor.
|
|
|