Infinite scroll pagination using php jquery and ajax

Infinite scroll pagination using php jquery and ajax

In this tutorial, we are going to learn how to create infinite scroll pagination using PHP jquery and ajax. we have seen on Facebook, Twitter, or other websites on that automatically loaded content when scrolling down to the web page.

So you can follow the below steps and see our example for mouse scroll pagination in Php.

Overview

Create a Database and Table

Connect to Database

Get the limit data

Get the infinite data

Create a Database and Table

First of all for we will create a database and table. after then we will add dummy data in the table. here we take the products table and also added products related data into the product table. so you can see the below code.

Connect to Database

Here in this step, we will create a config.php file and connect the MySQL with PHP. so you can see the below code for configuration.

config.php

Get the limit data

Here in this step, we have to need limited data for display data. so we are displaying 10 data per rows. for that, we will take a constant variable so we can display 10 data per rows. now here we will take two hidden inputs filed for the current row position and the total number of rows.

So you can see below code for the first time get rows records.

Get the infinite data

Here in this step, we have used some functions. you can see it.

$(window).scrollTop() function when scroll then it will return current vertical position.

$(document).height() function return height of the document.

$(window).height() function return pixel value of the height of the (browser) window.

When we scroll down if the current position and bottom position are the same then it will be passed next current row data using ajax and call into pagination.php file. after it will be helpful for getting limit data into the query.

We have suggested if you still do not read our article related article then you can read our article related article. How To Create Pagination With PHP And MySql

Please follow and like us: