This post explains you about how to implement Twitter Style PHP Ajax Load More Pagination.

In modern days load more pagination is very popular. Twitter is the most popular example for the same. And if you are looking for traditional ajax based pagination than please visit my previous article PHP Ajax Pagination Tutorial

 

Download Link   Demo Link

 

Sample database design for table name contact.

This table contains id (primary key), name and age.

CREATE TABLE IF NOT EXISTS `pagination` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `post` varchar(250) NOT NULL,
  `postlink` varchar(250) NOT NULL,
  PRIMARY KEY (`id`)
)

dbConnect.inc.php

Contains database connectivity code

$mysql_db_hostname = "Host name";
$mysql_db_user = "UserName";
$mysql_db_password = "Password";
$mysql_db_database = "Database Name";

$con = mysql_connect($mysql_db_hostname, $mysql_db_user,
       $mysql_db_password or die("Could not connect database");
//Create a new connection
mysql_select_db($mysql_db_database, $con) or
                 die("Could not select database");
// select database

style.css  
Contain css code.

.noneLink{display:none;)

index.php
Contain pagination display code and ajax logic

AJAX CODE

<script type="text/javascript">
function loadData(pageLimit){
     $(".flash").show();
     $(".flash").fadeIn(400).html
            ('Loading <img src="image/ajax-loading.gif" />');
     var dataString = 'pageLimit='+ pageLimit;
     $.ajax({
             type: "POST",
             url: "pageData.php",
            data: dataString,
            cache: false,
            success: function(result){ 
            $(".flash").hide();
            $(".load_more_link").addClass('noneLink');
            $("#pageData").append(result);
      }
  });
}
  loadData('0');
</script>

 

<div id="wrapper">
   <div id="pageData"></div>
 </div>

pageData.php
Contain display data.

<?php
$per_page=8;
include_once('inc/dbConnect.inc.php');
if(isset($_POST['pageLimit']) && !empty($_POST['pageLimit'])){
    $pageLimit=$_POST['pageLimit'];
}else{
    $pageLimit='0';
}
$pageLimit=$pageLimit;
$query="select id,post,link from pagination order by id desc
        limit $pageLimit,".$per_page;
$res=mysql_query($query);
$count=mysql_num_rows($res);
$HTML='';
if($count > 0){
   while($row=mysql_fetch_array($res)){
       $post=$row['post'];
       $link=$row['link'];
       $HTML.='<div>';
       $HTML.='<a href="'.$link.'" target="blank">'.$post.'</a>';
       $HTML.='</div><br/>';
    }
 $loadCount=$pageLimit+$per_page;
 if($count >= $per_page){
       $HTML.='<div class="load_more_link">';
       $HTML.='<input type="button" class="button" value="Load More"
       onclick=loadData("'.$loadCount.'")>';
       $HTML.='<span class="flash"></span></div>';
 }
}else{
       $HTML='No Data Found';
}
echo $HTML;
?>