How to use Pagination with Load More using Ajax in PHP?

Mar 21, 2022



How to use Pagination with Load More using Ajax in PHP?

Hi friends,

In this post, we will learn how to use pagination with Load More using Ajax in PHP. i explained simply step by step how to ajax load more pagination in PHP. Here you will learn how to make ajax load more content, using button pagination in PHP. This tutorial will give you simple example of how to load more results in PHP, Ajax and MySQL from Database.

I will give you simple Example of how to Ajax based load more results with jQuery, MySQL and PHP.

So let's see bellow example:


<!DOCTYPE html>

<html lang="en">


<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>PHP Ajax Pagination with Load More -</title>

<link rel="stylesheet" href="">

<script src=""></script>



<div class="container mt-5">

<div class="row">

<div class="col-md-12">

<div class="card-header text-center bg-dark text-white">

<h4>PHP Ajax Pagination with Load More -</h4>


<table class="table table-bordered" id="loadData">














<script type="text/javascript">



function loadMoreData(page){


url : "load.php",

type: "POST",




if (data) {




$(".loadbtn").prop("disabled", true);

$(".loadbtn").html('That is All');





$(document).on('click', '.loadbtn', function(){


var pId = $(this).data("id");









$sernamename = "localhost";

$username = "root";

$passoword = "";

$databasename= "demos";

$con = new mysqli($sernamename, $username,$passoword,$databasename);

if ($con->connect_error) {

die("Connection failed". $con->connect_error);


$limit = 5;

if (isset($_POST['page_no'])) {

$page = $_POST['page_no'];


$page = 0;


$sql = "SELECT * FROM users LIMIT $page, $limit";

$query = $con->query($sql);

if ($query->num_rows > 0) {

$output = "";

$output .= "<tbody>";

while ($row = $query->fetch_assoc()) {

$last_id = $row['id'];









$output .= "<tbody>";

$output .= "<tbody id='pagination'>


<td colspan='5'><button class='btn btn-success loadbtn' data-id='{$last_id}' style='margin-left:500px'>Load More</button></td>



echo $output;




I hope it will help you....