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

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

Read Also:  ANGULARJS PHP MySQL Inline CRUD Example Tutorial From Scratch

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

Read Also:  PHP Codeigniter load data while Ajax Infinite scrolling Pagination

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. Read Also:  Select DropDown Option Selected In Laravel
  2. Read Also:  Check WordPress Plugin Dependencies
  3. Read Also:  load data dynamically on page scroll using jquery ajax and php
  4. Read Also:  Redirect HTTP To HTTPS Using Laravel Middleware
  5. Read Also:  How to Check If String Contains a Substring in PHP
  6. Read Also:  vue js image slider - carousel multiple image slider with thumbnail
  7. Read Also:  Pop Push Shift Unshift Array Methods
  8. Read Also:  Create First WordPress Plugin Step by Step for Beginners
  9. Read Also:  Laravel Number of days between two inputted dates
  10. Read Also:  Dropdown ng-change Event using Angular Example
CLOSEX