1. Start
  2. About
  3. How it works?
  4. How to use it?
  5. About Files and Folders
  6. Other Things

Ajax MySQL Content Pagination

Split MySQL Content in Seconds


An easy way to paginate content from MySQL. Refresh and AJAX modules included.

About


This is a php class made for split into pages content from mysql tables.

You have the two methods of paging content with refresh and with ajax, 3 navigation systems and several template files for displaying items in the database.

You can make settings in three ways:

How it works?


This class make a query into mysql in the specified table with some requests made in "where" field and then display content using a template, like this:

Ajax version makes the above steps first time, when it displays the first page. After that, the remaining pages are displayed dynamically using JavaScript and XML generated by php.

If you need more articles in the same row you have to set float:left to the template class.
Number of articles in the same row is set in the settings file.

This class has 4 required attributes:

The other attributes are optional:

Settings
You can set some default values for

How to use it?


It is preferable not to move files from folders. If you do so be sure to change the path to the folders in all the files. Js,. Css,. Php.

To use the class:


Example of paging using AJAX/refresh without navbar

include "config.php"; // connection to mysql
include "util/settings.php";
include "class_pagination.php";
if(!isset($_GET['p'])) { $_GET['p']=$page; } // set page number for the first time

$pg = new pagination("table_name", "id>'1'", "template2.php", $_GET['p'], "antelink=demo.php?p=;");

//add first pagination system in the header of the list
$pg->navigation("1/2"); //   1/2 = current nav number/total nav number

//display articles from mysql
$item_in_row=$pg->item_in_row; $show=$pg->show;
$pg->display();

//add the second nav bar in the footer of the list
$pg->navigation("2/2");

#####################################################

Example of paging using refresh/AJAX with navbar

include "config.php"; // connection to mysql
include "util/settings.php";
include "class_pagination.php";
if(!isset($_GET['p'])) { $_GET['p']=$page; } // set page number for the first time

include "nav/nav_bar.php";

$pg = new pagination("table_name", "id>'1'", "template2.php", $_GET['p'], "antelink=demo.php?p=;".$attributes.$afterlink);

//add first pagination system in the header of the list
$pg->navigation("1/2"); //   1/2 = current nav number/total nav number

//display articles from mysql
$item_in_row=$pg->item_in_row; $show=$pg->show;
$pg->display();

//add the second nav bar in the footer of the list
$pg->navigation("2/2");

#####################################################

When you use AJAX version you have to include in the <head> of the file next line.

<script type="text/javascript" src="util/js.js"></script>

 

About Files and Folders


Folders

  1. docs - this folder with info
  2. img - contains images for navigation systems and a folder "producst" with pictures for demo articles
  3. nav - contains all the navigation files and navbar file
  4. page_tpl - contains templates to display content
  5. util - contains some useful files like js, css, settings and so on

Files

  1. the class is in root - class_pagination.php
  2. nav folder contains:
    1. two files for each navigation system from 1 to 3 (refresh) and 4(ajax) and 7(refresh)
    2. three files for each navigation system from 5 to 6 (ajax)
      all styles must be changed in the x_style.php files - where x is the number from 1 to 6
  3. 2 nav bar files
    1. nav bar only for refresh - 1 to 3
    2. nav bar only for ajax - 4 to 6
  4. 2 templates file in the page_tpl folder - you can create as many as you want :)
    1. master.php file in the same folder. Necessary for ajax version, loads template dinamically
  5. css.css and demo_template.css in the util folder - css for pagination class and for demo site
    1. in the same folder - js.js file for ajax
    2. settings.php - here you can make some settings for the pagination class
    3. variables.php - loaded by ajax version in order to save same variables in the input hidden fields
    4. xml.php - the file that creates the xml dinamically from mysql

Other Things


CSS

In the archive there are two css files

If you need to change the article box display you have to modify .article_box and/or .article_box2.
In order to display more articles from mysql in the same row you have to set float:left to tghe above class

The .loader_div class is for the layer/div that is put over the site when ajax is requesting content from mysql

JavaScript

If you want to disable the loader div you have to comment two lines in the js.js file

In line 106 is set a hide delay of 200 milliseconds in order to avoid the flicker of loading layer when the content is loaded fast.