TweetPagination is the process to split huge number of records in order to create dynamic pages. By using PHP we can easily setup a pagination script to display record from database. Pagination is mainly used in search result and displaying the table of content like name and address.
Above image will explain you how pagination will work? You can view demo or download the example file below and custimize to your requirement and layout.
Create a table in database
CREATE TABLE `articles` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR( 256 ) NOT NULL , `description` MEDIUMTEXT NOT NULL , `link` VARCHAR( 256 ) NOT NULL ) ENGINE = MYISAM ;
Copy and paste below code in index.php
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]); $page = ($page == 0 ? 1 : $page); $perpage = 8;//limit in each page $startpoint = ($page * $perpage) - $perpage;
After this make sure that you have included the Pagination.php in your index.php file.
We can use this type of pagination simply to display records from database. If you want to make pagination for search result we have to go for PHP Ajax Pagination System. I will explain this type of pagination system later.