Pagination with jQuery Ajax PHP and MySQL

Pagination with jQuery Ajax PHP and MySQL

In this Post We Will Explain About is Pagination with jQuery Ajax PHP and MySQL With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Simple Ajax Pagination with jQuery & PHP Example

In this post we will show you Best way to implement Simple jQuery AJAX Pagination with PHP and MySQL, hear for Pagination with jQuery, Ajax, PHP and MySQL with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also you can read my previous Articles Like pagination in php demo, dynamic pagination in php with mysql example, pagination code in php with next and previous demo

Read Also:  jQuery Ajax File Upload images using PHP MySQLi

Ajax Pagination Using jQuery, PHP And MySQL

In this Example,First of all Add or Inluce External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priorty set.After that Include your relavant CSS Class.

Create Database

first of all simple create MySQL studentList simple table contains two columns like as a stud_id and students simple pagination code in php with demo

Read Also:  How to make PHP Pagination With Example and Demo?

CREATE TABLE studentList
(
stud_id INT PRIMARY KEY AUTO_INCREMENT,
students VARCHAR(150)
);

JavaScript Code(index.js)

This js script works simple like a data some controller.

<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{

function loading_show()
{
$('#loading').html("<img src='images/loading.gif'/>").fadeIn('fast');
}

function loading_hide()
{
$('#loading').fadeOut();
} 

function loadData(live_page)
{
loading_show(); 
$.ajax
({
type: "POST",
url: "get_data.php",
data: "live_page="+live_page,
success: function(msg)
{
$("#live_data_get").ajaxComplete(function(event, request, settings)
{
loading_hide();
$("#live_data_get").html(msg);
});
}
});
}
loadData(1); 
$('#live_data_get .pagination li.active').live('click',function(){
var live_page = $(this).attr('p');
loadData(live_page);
}); 
});

</script>

get_data.php

In simple pagination in php with mysql example demo, Contains PHP some source coding.and then Displaying data from displaying the studentList table.

<?php
include('db_con.php');
if($_POST['live_page'])
{
$live_page = $_POST['live_page'];
$cur_page = $live_page;
$live_page -= 1;
$page_per_data = 15; // Per live_page records
$previous_btn = true;
$next_btn = true;
$first_btn = true;
$last_btn = true;
$start = $live_page * $page_per_data;
include"db_con.php";
$query_pag_data = "SELECT stud_id,students from studentList LIMIT $start, $page_per_data";
$result_pag_data = mysqli_query($query_pag_data);
$msg = "";
while ($row = mysqli_fetch_array($result_pag_data,MYSQLI_ASSOC)) 
{
$htmlmsg=htmlentities($row['students']); //HTML entries filter
$msg .= "<li><b>" . $row['stud_id'] . "</b> " . $htmlmsg . "</li>";
}
$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data
/* -----Total count--- */
$row_pageno = "SELECT COUNT(*) AS count FROM studentList"; // Total records
$datares_page = mysqli_query($row_pageno);
$row = mysqli_fetch_array($datares_page,MYSQLI_ASSOC);
$count = $row['count'];
$no_of_paginations = ceil($count / $page_per_data);

}
?>

db_con.php(config settings)

<?php
define('DB_SERVER', 'YOUR_LOCAL_SERVER);
define('DB_USERNAME', 'YOUR USERNAME');
define('DB_PASSWORD', 'YOUR PASSWORD');
define('DB_DATABASE', 'YOUR DATABASE Name');
$db_con = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>

You are Most welcome in my youtube Channel Please shubscibe my channel. and give me feedBackMore Details……
Angularjs Example

Read Also:  pagination code in php with next and previous demo

Example

I hope you have Got What is simple pagination code in php with example And how it works.I would Like to have FeaeBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel 6 Where null and Where not null eloquent query
  2. Read Also:  PHP Pagination demo – Pagination in PHP with example script
  3. Read Also:  Advanced Pagination with PHP, MySQL and jQuery Demo
  4. Read Also:  Angular 9/8 Radio Button on Form Submit
  5. Read Also:  Codeigniter 3 Get All Routes using Controller
  6. Read Also:  PHP Pagination Class tutorial with next and previous
  7. Read Also:  how to create controller in laravel through cmd?
  8. Read Also:  PHP Ajax Image Upload Resize Crop using jQuery
  9. Read Also:  jQuery ajax pagination in php MySQLi
  10. Read Also:  Passing data to views from routes in Laravel