Load more data on page scroll using jQuery, Ajax and PHP

Pagination, also known as paging, is the process of dividing a document into discrete pages.The dynamic record is loaded from the server automatically while scrolling page down. Infinite scrolling is a user-friendly way to load additional content on the web application. In this post, We have share how to implement Load more data on page scroll using jQuery, Ajax and PHP. This is a very simple example, you can just copy paste and change according to your requirement.
Before started to implement the Load more data on page scroll using jQuery, Ajax and PHP look files structure:
  • load-data-on-page-scroll-using-php-mysql-jquery
    • css
      • style.css
      • shimmer.css
    • images
    • templates
      • header.php
      • footer.php
    • config.php
    • fetch_record.php
    • index.php
Step 1: Create the database and Table
Run the following script against MySQL to create the database news table.
Step 2: Database Configuration (config.php)
The config.php file is used to connect and fetch record from database. You should change your username, password and database name. See the config.php file below.
Step 3: Load Data from Database (fetch_record.php)
The fetch_record.php file is called by the Ajax request on page scroll.
Step 4: Create index.php
Create a PHP file index.php to create HTML to display dynamically loaded record on page scroll.
Step 5: jQuery & Ajax Code:
We will also need to use jQuery code in index.php to load pagination and make Ajax request to load more records.
Step 6: Create header (header.php)
This view contains the header section of the webpage. The Bootstrap library is used to provide a better UI, so, include it in the header section.
Located at the top of a website, the header typically contains elements that include a company’s logo, website navigation, and contact information.
Step 7: Create a view file named footer.php
This view contains the footer section of the webpage.
  • jQuery – needed by Bootstrap JavaScript.
  • Bootstrap JavaScript – to make cool UI