Advanced Pagination with PHP, MySQL and jQuery Demo

Advanced Pagination with PHP, MySQL and jQuery

In this Post We Will Explain About is simple pagination code in php with example 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 Pagination with PHP, MySQL and jQueryExample

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

In this post we will show you Best way to implement Advanced Ajax Pagination PHP,MySQL Using jQuery, hear for Pagination with jQuery Ajax PHP and MySQLwith simple pagination code in php with demo Download .we will give you simple pagination in php with mysql example demo for implement Step By Step Good Luck!.

Table structure for table And Some Records

--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`users_name` varchar(255) NOT NULL COMMENT 'users name',
`user_fees` double NOT NULL COMMENT 'users salary',
`user_age` int(11) NOT NULL COMMENT 'users age',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='datatable demo table' AUTO_INCREMENT=58 ;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `users_name`, `user_fees`, `user_age`) VALUES
(1, 'Ram Shah', 356985, 61),
(2, 'jigar Shah', 22545, 63),
(3, 'Kinjal Dave', 98568, 66),
(4, 'Radha Mehta', 236545, 22),
(5, 'Sardha Kapoor', 524587, 33),
(6, 'Kali Baka', 698569, 61),
(7, 'Mari Janu', 22569, 59),
(8, 'Patnjali radhe', 56985, 55),
(9, 'Dipti patadiya', 98956, 39),
(10, 'Yogi mehta', 56898, 23);

PHP Code: “index.php”

<div class="container">
<?php
	$total_per_page = 10;
	//Calculating simple no of total pages
	$query = "SELECT id, users_name, user_fees, user_age FROM users";
	$data_result = mysqli_query($conn, $query);
	$data_count = mysqli_num_rows($data_result);
	$pages = ceil($data_count/$total_per_page)
?>

<div id="section_data"></div>
	<div id="livepaginate">
	<ul class="livepaginate">
	<?php
		//Pagination Numbers
		for($i=1; $i<=$pages; $i++)
		{
		echo '<li id="'.$i.'">'.$i.'</li>';
		}
	?>
	</ul>
	</div>
</div>

PHP Code: “custom_page_data.php”

 <?php
	$total_per_page = 10;
	if($_GET)
	{
		$page=$_GET['page'];
	}
$start = ($page-1)*$total_per_page;
$query = "select * from users order by id limit $start,$total_per_page";
$data_result = mysqli_query($conn, $query);
?>
<table class="table table-bordered">
	<?php
	while($row = mysqli_fetch_array($data_result))
	{
		$id=$row['id'];
		$user_name=$row['users_name'];
		$user_fees=$row['user_fees'];
		$user_age=$row['user_age'];
		?>
		<tr>
			<td><?php echo $id; ?></td>
			<td><?php echo $user_name; ?></td>
			<td><?php echo $user_fees; ?></td>
			<td><?php echo $user_age; ?></td>
		</tr>
		<?php
	}
	?>
</table>

Script Part – JavaScript code: (index.js)

 $(document).ready(function() {
 
	//simple Hide Loading Image
	function list_hide_data() {
		$("#loading").fadeOut('slow');
	};
	
	//Default all the  Starting Simple Page Results using jQuery
	$("#livepaginate li:first").css({'color' : '#FF0084'}).css({'border' : 'none'});
	$("#section_data").load("custom_page_data.php?page=1", list_hide_data());
	
	//Pagination per users Click
	$("#livepaginate li").click(function(){
		//your CSS Styles
		$("#livepaginate li").css({'border' : 'solid #AA59D2 1px'}).css({'color' : '#367CB5'});
		$(this).css({'color' : '#FF0084'}).css({'border' : 'none'});
		//simple Loading Data
		var pageNo = this.id;
		$("#section_data").load("custom_page_data.php?page=" + pageNo, list_hide_data());
	});
});

Example

Also Read This πŸ‘‰   Chosen Ajax Autocomplete Textbox using jQuery, PHP

I hope you have Got What is Simple ajax pagination in php with mysql example 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.