Skip to content

It is pagination library for php with mysql. It's create automatically generating navigation links.

License

Notifications You must be signed in to change notification settings

minisuperfiles/npage_pagination

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

npage_pagination

It is pagination library for php with mysql. It's create automatically generating navigation links.

Pagination preview

Including library file

require_once 'npage_pagination/npage_pagination.php';

Using Example

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>

Syntax (arguments)

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;

database

Give the database access details in an array format.

  1. hostname
  2. username
  3. password
  4. database
  5. port

query

Give the select query, it also supports join query and union query.

numofrows

Give the how many numbers record needs of a page.

npage_pagination methods
npage_pagination:get_query()
This method helps to get the query of the current page.
  • code : $npage->get_query();
npage_pagination:get_records($datatype)
This method is used to get the data of the current page. datatype argument helps to control get the return data type of records (array or object)
  • code : $npage->get_records('array');
npage_pagination:get_pageno()
This method helps to get the page number of the current page.
  • code : $npage->get_pageno();
npage_pagination:get_navigation()
This method use to get HTML navigation buttons
  • code : $npage->get_navigation();

Learn more about in minisuperfiles.blogspot.com

About

It is pagination library for php with mysql. It's create automatically generating navigation links.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages