

You can download the application:

On clicking the next button, the ajax function is called through this JQuery function
$("#next").click(function(){It sends the index of the next set of data to fetch, to the ajax function. On success the data in the view is updated and the index of current data set is updated. The checkVisible function is to ensure the next previous functionality. i.e, the Next button will be disables on reaching the last data set and the previous button will be disable on reaching the first data set.
var current = parseInt($("#currenthid").val()) + limit;
var data="current="+current;
$.ajax({
type:"POST",
url:"ajaxpost.php",
data:data,
cache:false,
success:function(html){
$("#showtable").html(html);
$("#currenthid").val(current);
checkVisible();
}
});
});
function checkVisible(){In the ajaxpost file the MySql database fetch is executed.
var current = parseInt($("#currenthid").val());
var total = parseInt($("#totalhid").val());
$("#previous").css('display','block');
$("#next").css('display','block');
if(current <>= total) {
$("#next").css('display','none');
}
}
$limitquery = "select id,name,category,price,discount from previousnext limit ".(int)$_REQUEST['current'].",".$limit;The data send from sql server is parsed in the php file and send to the client.
$result = mysql_query($limitquery, $dbHandle);
while($row = mysql_fetch_array($result)){In the next post i have planned to expand this application to have pagination. Donot forget to comment on my ideas.
echo "
".$row['id']."
".$row['name']."
".$row['category']."
".$row['price']."
".$row['discount']."
";
}