PHP Classes
elePHPant
Icontem

teaPagination: Display pagination for database queries using PDO

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (130)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2014-05-17 (2 years ago) RSS 2.0 feedNot enough user ratingsTotal: 424 This week: 2All time: 6,043 This week: 591Up
Version License PHP version Categories
teapagination 1.0.0BSD License3.0HTML, PHP 5, Data types
Description Author

This class can display pagination for database queries using PDO.

It can take an array with data to display or the SQL of a query to retrieve results to display.

The class can calculate the range of data records to display for the current page given the number of the current page and the limit of records to display per page.

It can generate HTML links to browse to other pages of the listing, as well iterate over the data records to display on the Web page using a given callback function.

Picture of Basilio
  Performance   Level  
Name: Basilio <contact>
Classes: 1 package by
Country: Spain Spain

Details
teaPagination
=============

teaPagination is a script that allows you to paginate a sql statement or an array of data, is powerful and flexible as it has all the functionality to page any data you want.
![Alt text](assets/img/datatable.png)
![Alt text](assets/img/listdata.png)

Installation
------------
<ol>
<li>Unzip the file on the server root</li>
<li>Included in their projects teaPagination.php file. 
<br/><br/>
<pre>&lt;?php require('your/path/teaPagination.php'); ?&gt;</pre>
<br/>
</li>
<li>Open in folder examples setting/setting.php and write your data connection to the database</li>
<li>Execute countries.sql in your database.</li>
<li>If you use the ajax page should include jquery plugin that is disposed within the header labels html document.
<br/><br/> 
<pre>&lt;script src="your/path/teaPaginate.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<br/>
</li>
</ol>

Features
--------
<ol>
<li>Easy to use, with a few lines of code get great results</li>
<li>Url and Ajax Pagination</li>
<li>Allows friendly url</li>
<li>The list is customizable</li>
<li>It is very extensible</li>
<li>has added a jquery plugin to interact with the server in the most simple</li>
</ol>

How to use
----------

<p>Before initializing the object must have prepared the data, which can be an array or sql query already formed.</p>
<pre>$data = 'Select * from countries'; /*or*/ $data = array('a','b','c','d');</pre>
<p>Set options for pagination</p>
<pre>$options = array();</pre>
<table><tr><td style="width:20%">Option</td><td style="width:50%">Description</td><td>Default Value</td></tr>
<tbody>
    <tr><td>maxButtons (integer)</td><td>Sets the number of buttons to display</td><td>5</td></tr>
    <tr><td>itemsPage (integer)</td><td>Number of rows to display</td><td>5</td></tr>
    <tr><td>beginLoop (string)</td><td>Sets string to the begin of the loop</td><td>NONE</td></tr>
    <tr><td>endLoop (string)</td><td>Sets string to the end of the loop</td><td>NONE</td></tr>
    <tr><td>beginTagItem (string)</td><td>Sets a string at the beginning of the iteration</td><td>NONE</td></tr>
    <tr><td>endTagItem (string)</td><td>Sets a string at the end of the iteration</td><td>NONE</td></tr>
    <tr><td>ajax (boolean)</td><td>It does not show the button link page</td><td>false</td></tr>
    <tr><td>nameVar (string)</td><td>Parameter name containing the page number</td><td>page</td></tr>
    <tr><td>urlPage (string)</td><td>Allows you to customize the output url</td><td>NONE</td></tr>
    <tr><td>textNotFound (string)</td><td>Text to be displayed when the data list is empty</td><td>Not found Record.</td></tr>
    <tr><td>connect_db (array)</td><td>This option sets the connection parameters to the database:<ol><li>user: name user</li><li>database: name database</li><li>password</li></ol></td><td>array('user' =&gt; '','database' =&gt; '','password' =&gt; '')</td></tr>
    <tr><td>buttons (array)</td><td>Customize output buttons:
            <ol>
                <li>btNext(boolean): Display the next button</li>
                <li>btNextTitle(string): Set button text</li>
                <li>btPrevious(boolean): Display the previous button</li>
                <li>btPreviousTitle(string): Set button text</li>
                <li>btFirst (boolean): Display first button</li>
                <li>btFirstTitle(string): Set button text</li>
                <li>btLast(boolean): Display last button</li>
                <li>btLastTitle(string): Set button text</li>
                <li>class(string): Define button styles</li>
            </ol></td><td>array('btNext' =&gt; true,'btNextTitle' =&gt; 'Next »','btPreviousTitle' =&gt; '« Previous','btPrevious' =&gt; true,'btLastTitle' =&gt; 'Last','btLast' =&gt; true,'btFirstTitle' =&gt; 'First','btFirst' =&gt; true,'class' =&gt; '')</td></tr>
</tbody>
</table>
<p>Create an instance of the class</p>
<pre>$pagination = new teaPagination($data, $options);</pre>
<p>Create the list using the loop method</p>
<pre>$pagination-&gt;loop($item_design, $callback=null, $callArgs=array());</pre>
<p><b>$item_design</b> is a string that replaces a word key by the value obtained from the data source. For example, if you have a field named 'lastName' that it replaced by its value chain adding the word {lastName}.
    <b>$callback</b> is a name function for display a more complete list, so calling an external function that will be called for each iteration of data. For example, to obtain a list of active users from the data source:
</p>
<pre>function create_list($data){if($data['user'] == 'active')return '&lt;div&gt;'.$data['name'].'&lt;/div&gt;';}</pre>
<p>And finally display the list and buttons</p>
<pre>echo $pagination-&gt;render(); /* list */ echo $pagination-&gt;buttons(); /* buttons */</pre>
<h3>Public variables:</h3>
<ul>
    <li><b>currentPage</b>: returns the current page number</li>
    <li><b>TotalPage</b>: returns total pages of the list</li>
    <li><b>TotalRecord</b>: returns total records of the list</li>
</ul>

JavaScript
----------
<p>For ajax paging to use the plugin for jquery teaPaginate.js, add the following line of code between the head tags in html document:</p>
<pre>&lt;script src="your/path/teaPaginate.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p>Now create the object for manipulation</p>
<pre>var element = document.getElementById('example');
var paginateExample = new teaPaginate(element,{    
    url : server.php,
    buttonsContainer : 'nameElement',
    OnLoad : handlePagerSuccess,
    OnBefore: handlePagerBefore,
    textLoading: 'Loading...',
    data:{page:1,init:true}
}).init();
</pre>
<br/>
<h3>Options:</h3>
<ul>
    <li><b>url</b>: url server</li>
    <li><b>buttonsContainer</b>: element that contains the buttons</li>
    <li><b>OnLoad</b>: processed function call after loading the list</li>
    <li><b>OnBefore</b>: processed function call before loading the list</li>
    <li><b>textLoading</b>: alternative text during the loading process</li>
    <li><b>data</b>: data sent to the server for processing (POST request)</li>
</ul>
<h3>Methods:</h3>
<ul>
    <li><b>update({data{options}})</b>: update the current page number (making a call to the server), data is sent (POST) to the server for processing.</li>
    <li><b>currentPage()</b>: return current page</li>
</ul>
		
Screenshots  
  • listdata.png
  • datatable
  Files folder image Files  
File Role Description
Files folder imageassets (1 directory)
Files folder imageexamples (12 files, 4 directories)
Files folder imagejs (1 file)
Files folder imageteaPagination (2 files, 3 directories)
Accessible without login Plain text file index.html Data Example Application
Accessible without login Plain text file LICENSE Lic. License
Accessible without login Plain text file README.md Doc. Auxiliary data
Plain text file teaPagination.php Class Class source

  Files folder image Files  /  assets  
File Role Description
Files folder imageimg (2 files)

  Files folder image Files  /  assets  /  img  
File Role Description
  Accessible without login Image file datatable.png Data Auxiliary data
  Accessible without login Image file listdata.png Data Auxiliary data

  Files folder image Files  /  examples  
File Role Description
Files folder imageassets (3 directories)
Files folder imagedebug (2 files)
Files folder imageextendsPaginate (1 file)
Files folder imagesetting (1 file)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login HTML file ajaxTable.html Doc. Documentation
  Accessible without login Plain text file ajaxTable.php Example Example script
  Accessible without login Plain text file ArrayData.php Example Sample output
  Accessible without login Plain text file countries.sql Data Auxiliary data
  Accessible without login HTML file customize.html Doc. Documentation
  Accessible without login Plain text file customize.php Example Example script
  Accessible without login Plain text file friendlyUrl.php Example Example script
  Accessible without login Plain text file itemReplace.php Example Example script
  Accessible without login Plain text file simple.php Example Example script
  Accessible without login HTML file simpleAjax.html Doc. Documentation
  Accessible without login Plain text file simpleAjax.php Example Example script

  Files folder image Files  /  examples  /  assets  
File Role Description
Files folder imagecss (1 file, 3 directories)
Files folder imageimages (11 files, 1 directory)
Files folder imagejs (3 files)

  Files folder image Files  /  examples  /  assets  /  css  
File Role Description
Files folder imagefont-awesome (2 directories)
Files folder imagefonts (1 file)
Files folder imagehighlight (1 file)
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data

  Files folder image Files  /  examples  /  assets  /  css  /  font-awesome  
File Role Description
Files folder imagecss (2 files)
Files folder imagefonts (1 file)

  Files folder image Files  /  examples  /  assets  /  css  /  font-awesome  /  css  
File Role Description
  Accessible without login Plain text file font-awesome.css Data Auxiliary data
  Accessible without login Plain text file font-awesome.min.css Data Auxiliary data

  Files folder image Files  /  examples  /  assets  /  css  /  font-awesome  /  fonts  
File Role Description
  Accessible without login Plain text file fontawesome-webfont.svg Data Auxiliary data

  Files folder image Files  /  examples  /  assets  /  css  /  fonts  
File Role Description
  Accessible without login Plain text file glyphicons-halflings-regular.svg Data Auxiliary data

  Files folder image Files  /  examples  /  assets  /  css  /  highlight  
File Role Description
  Accessible without login Plain text file default.css Data Auxiliary data

  Files folder image Files  /  examples  /  assets  /  images  
File Role Description
Files folder imageproducts (8 files)
  Accessible without login Image file addtocart.gif Icon Icon image
  Accessible without login Image file cart.gif Icon Icon image
  Accessible without login Image file compare.gif Icon Icon image
  Accessible without login Image file delete.png Icon Icon image
  Accessible without login Image file favorites.gif Icon Icon image
  Accessible without login Image file favs.gif Icon Icon image
  Accessible without login Image file products_details_bg.gif Icon Icon image
  Accessible without login Image file product_box_bottom.gif Icon Icon image
  Accessible without login Image file product_box_center.gif Icon Icon image
  Accessible without login Image file product_box_top.gif Icon Icon image
  Accessible without login Image file square-blue-add.gif Icon Icon image

  Files folder image Files  /  examples  /  assets  /  images  /  products  
File Role Description
  Accessible without login Image file camera.png Icon Icon image
  Accessible without login Image file iphone.png Icon Icon image
  Accessible without login Image file laptop1.gif Icon Icon image
  Accessible without login Image file laptop2.gif Icon Icon image
  Accessible without login Image file monitor.jpg Icon Icon image
  Accessible without login Image file pad.gif Icon Icon image
  Accessible without login Image file pc.jpg Icon Icon image
  Accessible without login Image file printer.jpg Icon Icon image

  Files folder image Files  /  examples  /  assets  /  js  
File Role Description
  Accessible without login Plain text file bootstrap.min.js Data Auxiliary data
  Accessible without login Plain text file highlight.pack.js Data Auxiliary data
  Accessible without login Plain text file jquery-1.7.2.min.js Data Auxiliary data

  Files folder image Files  /  examples  /  debug  
File Role Description
  Plain text file fb.php Class Class source
  Plain text file FirePHP.php Class Class source

  Files folder image Files  /  examples  /  extendsPaginate  
File Role Description
  Plain text file PaginateCustomize.php Class Class source

  Files folder image Files  /  examples  /  setting  
File Role Description
  Accessible without login Plain text file setting.php Conf. Sample output

  Files folder image Files  /  js  
File Role Description
  Accessible without login Plain text file teaPaginate.js Data Auxiliary data

  Files folder image Files  /  teaPagination  
File Role Description
Files folder imageDOC (1 file, 1 directory)
Files folder imageexamples (12 files, 4 directories)
Files folder imagejs (1 file)
  Accessible without login HTML file index.html Doc. Documentation
  Plain text file teaPagination.php Class Class source

  Files folder image Files  /  teaPagination  /  DOC  
File Role Description
Files folder imageassets (2 directories)
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files  /  teaPagination  /  DOC  /  assets  
File Role Description
Files folder imageblueprint-css (3 files, 2 directories)
Files folder imageimages (2 files)

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  blueprint-css  
File Role Description
Files folder imageplugins (4 directories)
Files folder imagesrc (7 files)
  Accessible without login Plain text file ie.css Data Auxiliary data
  Accessible without login Plain text file print.css Data Auxiliary data
  Accessible without login Plain text file screen.css Data Auxiliary data

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  blueprint-css  /  plugins  
File Role Description
Files folder imagebuttons (2 files, 1 directory)
Files folder imagefancy-type (2 files)
Files folder imagelink-icons (2 files, 1 directory)
Files folder imagertl (2 files)

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  blueprint-css  /  plugins  /  buttons  
File Role Description
Files folder imageicons (3 files)
  Accessible without login Plain text file readme.txt Doc. read me
  Accessible without login Plain text file screen.css Data style

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  blueprint-css  /  plugins  /  buttons  /  icons  
File Role Description
  Accessible without login Image file cross.png Icon image
  Accessible without login Image file key.png Icon image
  Accessible without login Image file tick.png Icon image

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  blueprint-css  /  plugins  /  fancy-type  
File Role Description
  Accessible without login Plain text file readme.txt Doc. read me
  Accessible without login Plain text file screen.css Data style

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  blueprint-css  /  plugins  /  rtl  
File Role Description
  Accessible without login Plain text file readme.txt Doc. read me
  Accessible without login Plain text file screen.css Data style

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  blueprint-css  /  src  
File Role Description
  Accessible without login Plain text file forms.css Data Auxiliary data
  Accessible without login Plain text file grid.css Data Auxiliary data
  Accessible without login Image file grid.png Icon css style
  Accessible without login Plain text file ie.css Data css style
  Accessible without login Plain text file print.css Data css style
  Accessible without login Plain text file reset.css Data css style
  Accessible without login Plain text file typography.css Data css style

  Files folder image Files  /  teaPagination  /  DOC  /  assets  /  images  
File Role Description
  Accessible without login Image file datatable.png Data Auxiliary data
  Accessible without login Image file listdata.png Data Auxiliary data

  Files folder image Files  /  teaPagination  /  examples  
File Role Description
Files folder imageassets (3 directories)
Files folder imagedebug (2 files)
Files folder imageextendsPaginate (1 file)
Files folder imagesetting (1 file)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login HTML file ajaxTable.html Doc. Documentation
  Accessible without login Plain text file ajaxTable.php Example Example script
  Accessible without login Plain text file ArrayData.php Output Sample output
  Accessible without login Plain text file countries.sql Data Auxiliary data
  Accessible without login HTML file customize.html Doc. Documentation
  Accessible without login Plain text file customize.php Example Example script
  Accessible without login Plain text file friendlyUrl.php Example Example script
  Accessible without login Plain text file itemReplace.php Example Example script
  Accessible without login Plain text file simple.php Example Example script
  Accessible without login HTML file simpleAjax.html Doc. Documentation
  Accessible without login Plain text file simpleAjax.php Example Example script

  Files folder image Files  /  teaPagination  /  examples  /  assets  
File Role Description
Files folder imagecss (1 file, 3 directories)
Files folder imageimages (11 files, 1 directory)
Files folder imagejs (3 files)

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  css  
File Role Description
Files folder imagefont-awesome (2 directories)
Files folder imagefonts (1 file)
Files folder imagehighlight (1 file)
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  css  /  font-awesome  
File Role Description
Files folder imagecss (2 files)
Files folder imagefonts (1 file)

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  css  /  font-awesome  /  css  
File Role Description
  Accessible without login Plain text file font-awesome.css Data style
  Accessible without login Plain text file font-awesome.min.css Data style

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  css  /  font-awesome  /  fonts  
File Role Description
  Accessible without login Plain text file fontawesome-webfont.svg Data font

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  css  /  fonts  
File Role Description
  Accessible without login Plain text file glyphicons-halflings-regular.svg Data font

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  css  /  highlight  
File Role Description
  Accessible without login Plain text file default.css Data css style

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  images  
File Role Description
Files folder imageproducts (8 files)
  Accessible without login Image file addtocart.gif Icon Icon image
  Accessible without login Image file cart.gif Icon Icon image
  Accessible without login Image file compare.gif Icon Icon image
  Accessible without login Image file delete.png Icon Icon image
  Accessible without login Image file favorites.gif Icon Icon image
  Accessible without login Image file favs.gif Icon Icon image
  Accessible without login Image file products_details_bg.gif Icon Icon image
  Accessible without login Image file product_box_bottom.gif Icon Icon image
  Accessible without login Image file product_box_center.gif Icon Icon image
  Accessible without login Image file product_box_top.gif Icon Icon image
  Accessible without login Image file square-blue-add.gif Icon Icon image

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  images  /  products  
File Role Description
  Accessible without login Image file camera.png Icon image
  Accessible without login Image file iphone.png Icon image
  Accessible without login Image file laptop1.gif Icon image
  Accessible without login Image file laptop2.gif Icon image
  Accessible without login Image file monitor.jpg Icon image
  Accessible without login Image file pad.gif Icon image
  Accessible without login Image file pc.jpg Icon image
  Accessible without login Image file printer.jpg Icon image

  Files folder image Files  /  teaPagination  /  examples  /  assets  /  js  
File Role Description
  Accessible without login Plain text file bootstrap.min.js Data Auxiliary data
  Accessible without login Plain text file highlight.pack.js Data Auxiliary data
  Accessible without login Plain text file jquery-1.7.2.min.js Data Auxiliary data

  Files folder image Files  /  teaPagination  /  examples  /  debug  
File Role Description
  Plain text file fb.php Class Class source
  Plain text file FirePHP.php Class Class source

  Files folder image Files  /  teaPagination  /  examples  /  extendsPaginate  
File Role Description
  Plain text file PaginateCustomize.php Class Class source

  Files folder image Files  /  teaPagination  /  examples  /  setting  
File Role Description
  Accessible without login Plain text file setting.php Output Sample output

  Files folder image Files  /  teaPagination  /  js  
File Role Description
  Accessible without login Plain text file teaPaginate.js Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 98%
Total:424
This week:2
All time:6,043
This week:591Up