Location: PHPKode > scripts > PHP AJAX pagination > php-ajax-pagination/test_sub.php
<?php
include('pagination_class.php');
mysql_connect('host name', 'user', 'password') or die(mysql_error());
mysql_select_db('dbname');
?><?
$qry = "SELECT * FROM students";

if($_REQUEST['search_text']!=""){
	$searchText = $_REQUEST['search_text'];
	$qry .=" where name like '$searchText%'";
}

//for pagination
if(isset($_GET['starting'])&& !isset($_REQUEST['submit'])){
	$starting=$_GET['starting'];
}else{
	$starting=0;
}
$recpage = 2;//number of records per page
	
$obj = new pagination_class($qry,$starting,$recpage);		
$result = $obj->result;
?>
<table border="1" align="center" width="100%">
<tr><TD>Sl no</TD><TD>Name</TD></tr>
<?if(mysql_num_rows($result)!=0){
	$counter = $starting + 1;
	while($data = mysql_fetch_array($result)) {?>
		<tr>
		<TD><? echo $counter; ?></TD>
		<TD><? echo $data['name']; ?></TD>
		</tr><?
		$counter ++;
	} ?>

		
	<tr><TD colspan="2"><? echo $obj->anchors; ?></TDcolspan="2"></tr>
	<tr><TD colspan="2"><? echo $obj->total; ?></TD></tr>
<?}else{?>
	<tr><TD align="center" colspan="2">No Data Found</TD></tr>
<?}?>
</TD></tr>
</table>
Return current item: PHP AJAX pagination