fastread homefastrread library fastread menu

PHP Tutorial : Load Data after page scroll down

Tutorial by:Admin      Date: 2016-04-14 02:32:28

❰ Previous Next ❱

Lets create a system where the records from mysql database will load after the user scroll down. This can be done with very simple php scripts and jQuery function.

jQuery Function



function scrollMore(){
if($(window).scrollTop() == ($(document).height() - $(window).height())){

var offset = $('[id^="myData_"]').length; 
var records = $(".allData").text();

if(records != offset){
$("#loaderImg").html('<img src="images/ajax-loader.gif" />');

function loadMoreData(offset){
type: 'get',
url: 'getMoreData.php',
data: 'offset='+offset,
success: function(data){
$(".loadData :last").after(data);
error: function(data){
alert("ajax error occured�"+data);


Write down the following code in getMoreData.php file.


$offset = (isset($_REQUEST['offset']) && $_REQUEST['offset']!='') ? 
$_REQUEST['offset'] : '';
$limit = 10;
$qry1 = mysql_query("select * from message limit ".$offset.", ".$limit."");
$i = ++$offset;
while($result = mysql_fetch_array($qry1)){ ?>
<div class="tableRow loadData" id="myData_<?php echo $i;?>">
<div class="firstColumn"><?php echo $i; ?></div>
<div class="secondColumn"><?php echo $result['url']?></div>
<?php $i++; } ?>

❰ Previous Next ❱

PHP Tutorial

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website