All Projects → dcblogdev → Pagination

dcblogdev / Pagination

Licence: mit
Paginate record sets, not tied in directly to a database.

Projects that are alternatives of or similar to Pagination

Go Tmdb
Golang Wrapper for TheMovieDB API
Stars: ✭ 70 (-2.78%)
Mutual labels:  hacktoberfest
Hacktoberfest2020
Contribute for hacktoberfest 2020
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest
Moviedb Promise
Interact with themoviedb.org's api with Node... now in TypeScript!
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest
Hacktoberfest 2020 Fizzbuzz
🎃 Submit creative/abstract FizzBuzz solutions in any language you want!
Stars: ✭ 71 (-1.39%)
Mutual labels:  hacktoberfest
Made In India
🇮🇳 A list of neat projects made in India.
Stars: ✭ 70 (-2.78%)
Mutual labels:  hacktoberfest
Dockerkit
Control your Docker Containers with HomeKit
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest
Gleebug
Debugging Framework for Windows.
Stars: ✭ 1,168 (+1522.22%)
Mutual labels:  hacktoberfest
Church Calendar Api
API providing Roman Catholic church calendar data for your apps
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest
Etcd
Development repository for the etcd cookbook
Stars: ✭ 71 (-1.39%)
Mutual labels:  hacktoberfest
Opentogethertube
Watch videos with your friends. The spiritual successor to TogetherTube, preserving the spirit of it's simple to use interface, while improving it's look, feel, and reliability.
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest
Hacktoberfest
Contribute to this repository to participate in hacktoberfest
Stars: ✭ 71 (-1.39%)
Mutual labels:  hacktoberfest
Laravel Disqus
A simple Disqus platform integration with Laravel.
Stars: ✭ 71 (-1.39%)
Mutual labels:  hacktoberfest
Micropipenv
A lightweight wrapper for pip to support requirements.txt, Pipenv and Poetry lock files or converting them to pip-tools compatible output. Designed for containerized Python applications but not limited to them.
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest
Chef Splunk
Development repository for the chef-splunk cookbook
Stars: ✭ 70 (-2.78%)
Mutual labels:  hacktoberfest
Edxposedmanager
Companion Android application for EdXposed
Stars: ✭ 1,172 (+1527.78%)
Mutual labels:  hacktoberfest
Chaos
🔥 CHAOS is a Remote Administration Tool that allow generate binaries to control remote operating systems.
Stars: ✭ 1,168 (+1522.22%)
Mutual labels:  hacktoberfest
Interview Prep
Everything you need to know to get the job
Stars: ✭ 69 (-4.17%)
Mutual labels:  hacktoberfest
Tsuru Client
tsuru-client is a tsuru command line tool for application developers.
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+1538.89%)
Mutual labels:  hacktoberfest
Country Coder
📍➡️ 🇩🇰 Convert longitude-latitude pairs to ISO 3166-1 codes quickly and locally
Stars: ✭ 72 (+0%)
Mutual labels:  hacktoberfest

pagination

Paginate record sets, not tied in directly to a database.

Usage

  1. include the class
  2. instantiate a new object pass in the number of items per page and the instance identifier, this is used for the GET parameter such as ?p=2
  3. pass the set_total method the total number of records
  4. show the records
  5. call the page_links method to create the navigation links
include('paginator.php');

$pages = new Paginator('10','p');
$pages->set_total('100'); //or a number of records

//display the records here

echo $pages->page_links();

if using a database you limit the records by placing $pages->get_limit() in your query, this will limit the number of records

select * from table $pages->get_limit()

by default the page_links method created links starting with ? this can be changed by passing in a parameter to the method:

echo $pages->page_links('&');

The method also allows you to pass in extra data such as a series of GET's

echo $pages->page_links('?','&status='.$_GET['status'].'&active='.$_GET['active']);

Database example

//include the class
include('paginator.php');

//create new object pass in number of pages and identifier
$pages = new Paginator('10','p');

//get number of total records
$stmt = $db->query('SELECT id FROM table');
$total = $stmt->rowCount();

//pass number of records to
$pages->set_total($total); 

$data = $db->query('SELECT * FROM table '.$pages->get_limit());
foreach($data as $row) {
    //display the records here
}

//create the page links
echo $pages->page_links();

MVC example

using this class in an MVC environment its almost the same, only the database or dataset calls come from the model instead of the page directly.

in the controller:

//create a new object
$pages = new Paginator('10','p');

//set the total records, calling a method to get the number of records from a model
$pages->set_total( $this->_model->get_all_count() );

//calling a method to get the records with the limit set
$data['records'] = $this->_model->get_all( $pages->get_limit() );

//create the nav menu
$data['page_links'] = $pages->page_links();

//then pass this to the view, may be different depending on the system
$this->_view->render('index', $data);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].