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??