Easy PHP Pagination

I’ve had a few pagination scripts over the years but I thought i’d share the one that i’m currently using as it’s a useful script to have in your website. As a developer you’ll soon find a need to paginate data when displaying contents from the database, and rather than use JavaScript which could require all the data to be loaded into the page on load, we can use PHP to ensure that we’re only requesting the data that we need from the database. For those who have no clue what i’m talking about. Pagination is a way of splitting up data into manageable chunks to display to a user, if you’ve spent more than two minutes on the internet chances are you’ve come into contact with some form of pagination. as a simple example you can checkout my website and allows you to split data up with it being paginated across however many pages dynamically.
 1)
	{	
	

	
	
		$pagination .= "";		
	
	
}
 echo $total_pages.' Results';
 // pagination
 echo $pagination;
?>

    '.$row['country'].' '; } ?>
Here’s the css to style you pagination

Jquery infinite scroll - with div

This code has been tested and verified as working. When you scroll your div, the code checks if the scroller reached to the bottom by comparing the scroller height against the scroller position. If so, it calls to a method that gets more content and append it to the div.

    
        Test 
        
        
    
        
            

This is the div content

This is the div content

This is the div content

This is the div content

This is the div content

This is the div content

Scroll Height:
Scroll position:

Simple AJAX - PHP and Javascript

this tutorial I will show you the most basic way to get a response from a PHP script.and we will start with the base object you need: a XMLHTTP Javascript object. With this object you call a server-side script and get the response back. Most browsers use the same Javascript object, but of course Microsoft has to be different, so they require their own. The following function will return the correct object:
function Inint_AJAX() {

   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE

   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE

   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript

   alert("XMLHttpRequest not supported");

   return null;

};
This code will, again, return an XMLHTTP object to use in our Javascript. What is going to happen is that we are going to use this object to make an HTTP request through Javascript. When we get a response back, we will simply place it in the page, nothing fancy. In order to make the request we use the following code:
function ajaxfun(src)

{

     var req = Inint_AJAX();

     req.onreadystatechange = function () { 

          if (req.readyState==4 && req.status==200) {

                  document.getElementById('divid').innerHTML=req.responseText; //retuen value
          }

     };

     req.open("GET", "demo.php?src="+src); //make connection

     req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header

     req.send(null); //send value

   

}