<?
/* this is an example which splits the query results into multiple pages as search engine does
you can change the query and format in which the result is being printed
*/
include("split.class.php3");
$sql="select title from master_course"; //query
$ord=new Split($sql,10); //create an object of split pass the sql and total no of rows to be displayed in a page
if($ord->error!="")
{
die("ERROR" . $ord->error);
}
$rows=$ord->display($ppage);
$pages=$ord->total(); //get the total no of pages
while($myrow=mysql_fetch_row($rows))
{
//print the results over here
printf("Name is $myrow[0]<br>"); //this is just a test value
}
//*******************************************************************************************
// now the split links to various pages will be displayed
//********************************************************************************************
if(($ppage=="")||($ppage<="0") )
{
$ppage=1; //as default if the requested page is less than 0 the first page is printed
}
if($ppage > $pages)
{
$ppage=$pages; //if the requested page is greater than total pages the last page is shown
}
if($ppage>1)
{
$backpage=$ppage-1;
printf("<a href=example.php3?ppage=$backpage>Back</a> ");
}
//echo $pages;
for($j=1;$j<=$pages;$j++)
{
if($j==$ppage)
{
echo $j;
}
else
{
printf("<a href=example.php3?ppage=$j>$j</a> ");
}
}
if($ppage<$pages)
{
$nextpage=$ppage+1;
printf("<a href=myexample.php3?ppage=$nextpage>Next</a> ");
}
?>
|