Data auto Load While scrolling page down with jquery PHP and MySQL

Ajax CSS JavaScript jQuery Laravel Mysql Mysqli php Programming Technology

Data auto Load While scrolling page down with jquery PHP and MySQL

In this Post We Will Explain About is Data auto Load While scrolling page down with jquery 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 Data Load While Page Scroll with jQuery PHP and MySQLExample

In this post we will show you Best way to implement load data dynamically on page scroll using jquery ajax and php, hear for Data auto Load While Page Scroll down with jQuery PHP and MySQLwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

File Structure List

Index.php
do_result_data.php
get_data_list.js

create a table structure

CREATE TABLE IF NOT EXISTS `postdata` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`comments` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Create Database Connection – db_connect.php

 Connect failed: %s\n", mysqli_connect_error());
	exit();
}
?>

Include External Libs





index.php

<div class="container">
<h2>Example: Simple Data Load While Page Scroll steps with jQuery PHP and MySQL Devloped By Pakainfo.com</h2>
	<div id="results">
		
	</div>
<div id="id_loader" style="text-align:center"><img src="id_loader.gif" /></div>
</div>

get_data_list.js

$(document).ready(function(){
	$(window).scroll(function(){
	if ($(window).scrollTop() == $(document).height() - $(window).height()){
		if($(".total_nopage:last").val() <= $(".get_total_rec").val()) {
			var nopage = parseInt($(".total_nopage:last").val()) + 1;
			loadRecord('do_result_data.php?get_page='+nopage);
			}
		}
	});
});
function loadRecord(url) {
	$.ajax({
		url: url,
		type: "GET",
		data: {get_total_rec:$("#get_total_rec").val()},
		beforeSend: function(){
			$('#id_loader').show();
		},
		complete: function(){
			$('#id_loader').hide();
		},
		success: function(data){
			$("#results").append(data);
		},
		error: function(){}
	});
}

do_result_data.php

<?php
include_once("db_connect.php");
$perPage = 3;
$sql_query = "SELECT id, comments FROM postdata";
$get_page = 1;
	if(!empty($_GET["get_page"])) {
	$get_page = $_GET["get_page"];
	}
$first = ($get_page-1)*$perPage;
	if($first < 0) $first = 0;
	$query = $sql_query . " limit " . $first . "," . $perPage;
	$query_results = mysqli_query($dbcon, $query) or die("database error:". mysqli_error($dbcon));
	$records = mysqli_fetch_assoc($query_results);
	if(empty($_GET["get_total_rec"])) {
	$_GET["get_total_rec"] = mysqli_num_rows($query_results);
	}
$msgdis = '';
	if(!empty($records)) {
		$msgdis .= '';
		$msgdis .= '';
			while( $rows = mysqli_fetch_assoc($query_results) ) {
			$msgdis .= '<div class="well">' .$rows["comments"] . '</div>';
			}
	}
	echo $msgdis;
?>

Example

I hope you have Got What is load data while scrolling page down with jquery and php 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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Show-Hide Password in TextBox with Button using jQuery
  2.   call to undefined function mysql_pconnect()
  3.   Concatenation string and Class in VueJS
  4.   Great UNIX Commands Tutorial for Beginners
  5.   Dynamically Upload Multiple Images Using PHP and jQuery
  6.   How to Merge Two Eloquent Collections in Laravel?
  7.   Select DropDown Option Selected In Laravel
  8.   PHP Codeigniter load data while Ajax Infinite scrolling Pagination
  9.   AngularJS Create Custom SEO Friendly URL Slugs
  10.   PHP MySQL Inline Editing Dynamically using jQuery Ajax

Leave a Reply

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