View Single Post
Old 04-17-2009, 09:20 PM   #1 (permalink)
allworknoplay
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default Help with class....

Ok, I am working on a pagination class, I figured I will break up the "methods" and figure them out one at a time instead of trying to write a class with 10+ methods...so I am going to do one at a time, make sure I get the results, and eventually combine everything together.

But I am having a problem already, I keep getting a blank page.



Here's my class file.

Code:
<?

class pagination {

/* GENERATE LINKS ex: 1 2 3 4 5 6 7 8 */
public function getPageLinks(int $page_last,int $get_page) {

$this->pageLast = $page_last;
$this->getPage = $get_page;
	
for ($i=1; $i<=$this->pageLast; $i++) { 

if(($this->getPage - 2) == $i) $display_pages[] = " <a href=\"$_SERVER[PHP_SELF]?p=$i\">$i</a>";
if(($this->getPage - 1) == $i) $display_pages[] = " <a href=\"$_SERVER[PHP_SELF]?p=$i\">$i</a>";
if($this->getPage == $i) $display_pages[] = "$i";
if(($this->getPage + 1) == $i) $display_pages[] = " <a href=\"$_SERVER[PHP_SELF]?p=$i\">$i</a>";
if(($this->getPage + 2) == $i) $display_pages[] = " <a href=\"$_SERVER[PHP_SELF]?p=$i\">$i</a>";

	}
		
return $this->displayPages = $display_pages;
			
}
		
		

}###END CLASS
	
?>

Here's my HTML.

Code:
<?

include_once("pagination.php");

/* LETS SET SOME VARIABLES TO SIMULATE USER EXPERIENCE */
$page_limit = 25;
$get_page = 7;
	
/* ARRAY WILL SIMULATE DATABASE ENTRIES */
$array = array(1,2,3,4,5,6,7,8,9,10);
$totalrows = count($array);
$page_last = 10;

/* CREATE OBJECT */
$pagination = new pagination();

$display_links = $pagination->getPageLinks(int $page_last,int $get_page);
	
echo "implode(' ',$display_links)";

?>


Since the current page is set to 7. I am giving it the last page which is 10, and the current page 7.


So anyways, the output should be: 5 6 7 8 9

But instead it's just blank??
allworknoplay is offline  
Reply With Quote