It is pagination library for php with mysql. It's create automatically generating navigation links. latest version 1.0
require_once 'npage_pagination/npage_pagination.php';
require_once "npage_pagination/npage_pagination.php"; // including npage pagination file $npage = new npage_pagination( array( 'hostname' => "localhost", // host name 'username' => "root", // user name 'password' => "", // password 'database' => "demo_proj" //database name ), "SELECT * FROM `st_order`", //your query 2 // number of records ); // create object $data = $npage->get_records(); //get record from database in array format
<div class="container"> <h1>nPage pagination - Page - <?php echo $npage->get_pageno(); // Get current page No ?> </h1> <?php if($data) { ?> <table class="table table-hover"> <thead> <tr> <?php $keys = array_keys($data[0]); for ($i = 0; $i < count($keys); $i++) { ?> <th><?php echo $keys[$i]; ?></th> <?php } ?> </tr> </thead> <tbody> <?php // print dynamic data for ($i = 0; $i < count($data); $i++) { ?> <tr> <?php for ($j = 0; $j < count($keys); $j++) { ?> <td><?php echo $data[$i][$keys[$j]]; ?></td> <?php } ?> </tr> <?php } ?> </tbody> </table> <?php } else { ?> No records <?php } ?> <?php echo $npage->get_navigation(); // print navigation button ?> </div>
new npage_pagination($database, $query, $numofrows); $database = array( 'hostname' => "host_name", 'username' => "user_name", 'password' => "password", 'database' => "database_name", 'port' => 3306 ); $query = "SELECT * FROM TABLENAME"; $numofrows = 10;
Give the database access details in an array format.
Give the select query, it also supports join query and union query.
Give the how many numbers record needs of a page.
npage_pagination:get_query()
$npage->get_query();
npage_pagination:get_records($datatype)
$npage->get_records('array');
npage_pagination:get_pageno()
$npage->get_pageno();
npage_pagination:get_navigation()
$npage->get_navigation();
No comments:
Post a Comment