Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php3

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Sandeep Raja  >  SplitResults  >  example.php3  >  Download  
File: example.php3
Role: ???
Content type: text/plain
Description: just an example
Class: SplitResults
Splits the database result across multiple pages
Author: By
Last change:
Date: 13 years ago
Size: 1,640 bytes
 

Contents

Class file image Download
<?


/* 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>&nbsp;&nbsp;&nbsp;");

}
//echo $pages;
for($j=1;$j<=$pages;$j++)
{
	if($j==$ppage)
	{
		echo $j;
	}
	else
	{
                printf("<a href=example.php3?ppage=$j>$j</a>&nbsp;&nbsp;&nbsp;");
	}		
}
if($ppage<$pages)
{
	$nextpage=$ppage+1;	
        printf("<a href=myexample.php3?ppage=$nextpage>Next</a>&nbsp;");

}
?>