Pagination with jQuery Ajax PHP and MySQL

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!.

Read Also:  CSS Create Middle Border Line After Text Example

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

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:  jQuery ajax pagination in php MySQLi

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:  Simple PHP Pagination Example Tutorial

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.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *