PHP MySQL Infinite Scroll Pagination

Today, We want to share with you PHP MySQL Infinite Scroll Pagination.In this post we will show you Infinite Scroll in PHP Using Jquery AJAX and MySQL, hear for Load Data on Page Scroll from MySQL Database using jQuery Ajax PHP we will give you demo and example for implement.In this post, we will learn about PHP – Infinite Scroll Pagination using JQuery Ajax Example with an example.

PHP MySQL Infinite Scroll Pagination

There are the Following The simple About PHP MySQL Infinite Scroll Pagination Full Information With Example and source code.

As I will cover this Post with live Working example to develop Infinite Scroll of Webpage in PHP, so the tutorial infinite scroll jquery ajax demo for this example is following below.

Read Also:  Select DropDown Option Selected In Laravel

Step 1: Database Connection

Config.php

mysql_connect("localhost","root","atmiya25");
mysql_select_db("pakainfo_test");

Step 2: Root Page PHP & HTML Script

Index.php

<script type="text/javascript" src="jquery.js"></script>
  <script type="text/javascript">
$(document).ready(function(){

    $(window).scroll(function (){
  
   //simple jQuery Ajax check if the users are at bottom of the window
   //scroll to returns 0
     
		if ($(window).scrollTop() + $(window).height() >= $(document).height())
	   {
		fetchPostDataLive();
	   }
    });

    function fetchPostDataLive()
    {
    var ids= $('.web-post:last').attr("id");
    
      $.ajax({
      type: 'post',
	  asynch: false,
      url: 'fetch_product_list.php',
	  cache: false,
      data: {
       getproductdata:ids
      },
      success: function (response) {
    //appending the result fetch_product_list page result with div id data_preview
  $('#data_preview').append(response);
      }
      });
    }
	});
</script>


<div class="row" id="data_preview">
<?php
Include(‘config.php’);

$sql= mysql_query("select * from `products` ORDER BY `product_id` DESC LIMIT 5");
while($rows=mysql_fetch_array($sql))
{?>
<div class="web-post" id="<?php echo  $rows['product_id'];?>"><?php
echo $rows['product_id']."<br><br><br><br>";
echo $rows['product_name']."<br><br><br><br>";
?>
</div>
<?php
}?>

</div>

Step 3 : PHP Script

fetch_product_list.php

<div class="row" >
<?php 
Include(‘config.php’);
mysql_select_db('pakainfo_demo', $connection);

if(isset($_POST['getproductdata']))  {
 
$total_lim=$_POST['getproductdata']; 
 
$sql_product= mysql_query("select * from `products` WHERE `product_id`<'$total_lim' ORDER BY `product_id` DESC limit 10");

while($rows=mysql_fetch_array($sql_product))
{?>
<div class="web-post" id="<?php echo  $rows['product_id'];?>"><?php
echo $rows['product_id']."<br><br><br><br>";
echo $rows['course_name']."<br><br><br><br>";
?>
</div>
<?php
}}?>
</div>

Step 4: Style

Css Part

.web-post{
width:900px;
height:200px;
background-color:pink;
border:1px solid #3d3d3d;
margin-left:200px;
margin-right:200px;
}
#datarow{
width:900px;
height:200px;
background-color:pink;
border:1px solid #3d3d3d;
margin-left:200px;
margin-right:200px;
}

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  jQuery Facebook Like Infinite Scroll Pagination in PHP MySQLi

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP MySQL Infinite Scroll Pagination.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.