Advanced jQuery Ajax Pagination PHP MySQL using jQuery

Advanced jQuery Ajax Pagination PHP MySQL using jQuery

In this Post We Will Explain About is Advanced jQuery Ajax Pagination PHP MySQL using jQuery With Example and Demo.

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

Welcome on Pakainfo.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to simple pagination code in php with example

In this post we will show you Best way to implement simple pagination in php with mysql example demo, hear for How to How to create pagination in PHP and MySQL with AJAX with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Pagination with Jquery PHP Ajax and MySQL

Using Simple PHP, we will display the all the Comments from the MySQL simple database with the simple PHP pagination ul or li links. so this simple pagination all the li links, we can get simple the database records except the all displayed records. using jQuery and Ajax call will help to simple get the PHP records from the Mysql database simple depending on all the Ul or li pagination links simple without reloading any PHP the page.

There are all the following files and simple folder will participate on simple pagination code in php with demo and mysql
-Database
-index.php
-load_data.php
-db.php

Database

CREATE TABLE comments
(
	msg_id INT PRIMARY KEY AUTO_INCREMENT,
	message VARCHAR(150)
);

JavaScript Code

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{

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

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

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

</script>

load_data.php
<?php
include('db.php');
if($_POST['live_page'])
{
	$live_page = $_POST['live_page'];
	$cur_page = $live_page;
	$live_page -= 1;
	$total_per_page = 10; 
	$previous_btn = true;
	$next = true;
	$first_btn = true;
	$last_btn = true;
	$start = $live_page * $total_per_page;
	include"db.php";
	$query_pag_data = "SELECT msg_id,message from comments LIMIT $start, $total_per_page";
	$result_pag_data = mysqli_query($query_pag_data);
	$msg = "";
	while ($row = mysqli_fetch_array($result_pag_data,MYSQLI_ASSOC)) 
	{
		$htmlmsg=htmlentities($row['message']); 
		$msg .= "<li><b>" . $row['msg_id'] . "</b> " . $htmlmsg . "</li>";
	}

	$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; 

	$query_pag_num = "SELECT COUNT(*) AS count FROM comments"; 
	$total_pageno = mysqli_query($query_pag_num);
	$row = mysqli_fetch_array($total_pageno,MYSQLI_ASSOC);
	$count = $row['count'];
	$no_of_paginations = ceil($count / $total_per_page);
}
?>

db.php

<?php
define('DB_SERVER', 'Pakainfo.com');
define('DB_USERNAME', 'atmiya25');
define('DB_PASSWORD', '[email protected]$%85');
define('DB_DATABASE', 'database');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
?>

Example

I hope you have Got Pagination with jQuery Ajax PHP and MySQL And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.