how can i load data page by page in php paging?

Load your first 30 datasets from the database, Then when the page has finished loading use ajax to send a request to the server to fetch the remaining records in batches of 30.

// ajax call to PHP script for processing.
var n= 1;
(function yourfunction () 
{

    $.ajax
    ({
        url:"yourphpscript.php",
        type:"POST",
        data:{'n':n},
        success:function(response)
        {
                        
            $("#the-display-area").append(response); 
            n+=1;//counter increement
        }
     })
})();

//PHP code to accept the post data of n from the ajax call and use it to query the 
database 

$n=$_POST["n"];
$n=$n*30;

    
$query = "SELECT * FROM yourtable LIMIT 30 OFFSET $n";

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top