How to add more button like twitter in php and mysql ajax

how to add more button for display post like twitter in kohana frame work. can any body give idea to do. i refer this link Load more like facebook or old twitter using php-mysql-jquery - Hycus

i have take the contents and display it in view.but dont know how to append it to current page . if i call the function it return the default view of my html p age how to get actual view page from my controller

Do you have a loadmore.php page which queries your database for the next set of records? It should be something like this.

Your posts page

<html>
<head>
<script>
$(document).ready(function(){
	$("#loadmorebutton").click(function (){
    	$('#loadmorebutton').html('');
	$.ajax({
		url: "http://site.com/scripts/loadmore.php?lastid=" + $(".postitem:last").attr("id"),
		success: function(html){
			if(html){
				$("ul#posts").append(html);
				$('#loadmorebutton').html('Load More');
			}else{
				$('#loadmorebutton').replaceWith('No more posts to show.');
			}
		}
	});
   });
});
</script>
</head>
<body>
<?php
if($posts = $db->get_results("SELECT id,text FROM posts ORDER BY id DESC LIMIT 10")) {
	echo '<ul id="posts">';
	foreach($posts as $post) {
		echo '<li class="postitem" id="'.$post->id.'">'.$post->text.'</li>';
	}
	echo '</ul>';
}
?>
<button id="loadmorebutton">Load More</button>
</body>
</html>

loadmore.php

<?php
if($_GET['lastid']){
	if($posts = $db->get_results("SELECT id,text FROM posts WHERE id < ".$db->escape($_GET['lastid'])." ORDER BY id DESC LIMIT 10")) {
		foreach($posts as $post) {
			echo '<li class="postitem" id="'.$post->id.'">'.$post->text.'</li>';
		}
	}
}
?>