Where do I add that code, demo.php or pmcPagination.php
?

To give an example of an error, I had, I ran the database script that checks the records for me that you mentioned here:
http://www.daniweb.com/forums/post1137603.html#post1137603

and it found the programmes that air at 11:25pm (UK time) tonight and 9:30am (UK time GMT) tomorrow, both of which didn't show up when I queried it.

I don't know why this happens... is it to do with phpmyAdmin or something else?

In the paginate function (comment everything inside of that functions out first) in pmcPagination.php.

Is this the code to comment out:

public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Prevent set function form changing values
		$this->paginated = true;
		
		//Set pageVar if arg is valid
		if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
		//Set parVar to previous value
		else $pageVar = $this->pageVar;
		
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		//Set resultsPerPage to previous value
		else $resultsPerPage = $this->resultsPerPage;
		
		//Add any extra items
		$this->add($items);
		
		//Get Page #, Staring Result #, and Ending Result #
		if(isset($_GET[$pageVar]) && $_GET[$pageVar] > 0) $page = $_GET[$pageVar];
		else $page = 1;
		$result = ($page - 1) * $resultsPerPage + 1;
		$max = $result + $resultsPerPage;
		if($max >= count($this->items)) $max = count($this->items);
		
		//Are there results?
		if($result<count($this->items))
		{
			//Cycle through results on current page
			for(;$result<$max;$result++)
		 	{
				//Show the result 
				$this->items[$result]->display();
		 	}
		}
		//Display a "no results" message
		else echo "<strong>No Results found on this page.</strong>";
	}
	
	public function navigation()
	{
		//Get Pag #
		if(isset($_GET[$this->pageVar]) && $_GET[$this->pageVar] > 0) $page = $_GET[$this->pageVar];
		else $page = 1;
		
		//Start Nav
		echo '<div id="nav">'."\n";
		
		//Show the Previous Link
		if($page==1) echo "<span>&laquo; Previous</span> ";
		else echo "<a href='?".$this->pageVar."=".($page-1)."'>&laquo; Previous</a> ";
		
		//Show the Number Links
		for($p=1;$p<=ceil(count($this->items)/$this->resultsPerPage);$p++)
		{
			if($p==$page) echo "<strong>{$p}</strong> ";
			else echo "<a href='?".$this->pageVar."={$p}'>{$p}</a> ";
		}
		
		//Show the Next Link
		if($page==ceil(count($this->items)/$this->resultsPerPage)) echo "<span>Next &raquo;</span><br>";
		else echo "<a href='?".$this->pageVar."=".($page+1)."'>Next &raquo;</a><br>";
		
		//End Nav
		echo '</div>'."\n";
	}

Just the code inside this function:

public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Prevent set function form changing values
		$this->paginated = true;
 
		//Set pageVar if arg is valid
		if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
		//Set parVar to previous value
		else $pageVar = $this->pageVar;
 
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		//Set resultsPerPage to previous value
		else $resultsPerPage = $this->resultsPerPage;
 
		//Add any extra items
		$this->add($items);
 
		//Get Page #, Staring Result #, and Ending Result #
		if(isset($_GET[$pageVar]) && $_GET[$pageVar] > 0) $page = $_GET[$pageVar];
		else $page = 1;
		$result = ($page - 1) * $resultsPerPage + 1;
		$max = $result + $resultsPerPage;
		if($max >= count($this->items)) $max = count($this->items);
 
		//Are there results?
		if($result<count($this->items))
		{
			//Cycle through results on current page
			for(;$result<$max;$result++)
		 	{
				//Show the result 
				$this->items[$result]->display();
		 	}
		}
		//Display a "no results" message
		else echo "<strong>No Results found on this page.</strong>";
	}

As I said, comment it out, and add:

print_r($this->items);

I did that, but nothing showed up on screen... just blankness on the page.

Impossible, you should have at least see:

Array
(
)

Something must be wrong. Can you post the pmcPagination.php file so I can make sure that you put the print_r in the right place?

This is the pmcPagination.php code:

<?php
/***********************************
 * PhpMyCoder Paginator            *
 * Created By PhpMyCoder           *
 * 2010 PhpMyCoder                 *
 * ------------------------------- *
 * You may use this code as long   *
 * as this notice stays intact and *
 * the proper credit is given to   *
 * the author.                     *
 ***********************************/
 
class pmcPagination {
	private $pageVar = "page";     //$_GET variable to get page # from
	private $items = array();      //Array of items to paginate
	private $resultsPerPage = 10;  //Results to be displayed per page
	private $paginated = false;    //Has the paginate() function been called?
	
	public function __construct($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Set pageVar if arg is valid
		if($this->isValidPageVar($pageVar)) $this->pageVar = $pageVar;
		
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		
		//Add items passed
		$this->add($items);
	}
	
	public function add($items)
	{
		//If the item is null, exit function
		if(is_null($items)) return;
				   
		//If arg is not an array, make it one
		if(!is_array($items)) $items = array($items);
		
		//Cycle through items passed
		foreach($items as $item)
		{
			//Add them to the $items array if they are valid
			if($item instanceof paginationData) $this->items[] = $item;	
		}
	}
	
	public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Prevent set function form changing values
		$this->paginated = true;
		
		//Set pageVar if arg is valid
		if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
		//Set parVar to previous value
		else $pageVar = $this->pageVar;
		
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		//Set resultsPerPage to previous value
		else $resultsPerPage = $this->resultsPerPage;
		
		//Add any extra items
		$this->add($items);
		
		//Get Page #, Staring Result #, and Ending Result #
		if(isset($_GET[$pageVar]) && $_GET[$pageVar] > 0) $page = $_GET[$pageVar];
		else $page = 1;
		$result = ($page - 1) * $resultsPerPage + 1;
		$max = $result + $resultsPerPage;
		if($max >= count($this->items)) $max = count($this->items);
		
		//Are there results?
		if($result<count($this->items))
		{
			//Cycle through results on current page
			for(;$result<$max;$result++)
		 	{
				//Show the result 
				$this->items[$result]->display();
		 	}
		}
		//Display a "no results" message
		else echo "<strong>No Results found on this page.</strong>";
	}
	
	public function navigation()
	{
		//Get Pag #
		if(isset($_GET[$this->pageVar]) && $_GET[$this->pageVar] > 0) $page = $_GET[$this->pageVar];
		else $page = 1;
		
		//Start Nav
		echo '<div id="nav">'."\n";
		
		//Show the Previous Link
		if($page==1) echo "<span>&laquo; Previous</span> ";
		else echo "<a href='?".$this->pageVar."=".($page-1)."'>&laquo; Previous</a> ";
		
		//Show the Number Links
		for($p=1;$p<=ceil(count($this->items)/$this->resultsPerPage);$p++)
		{
			if($p==$page) echo "<strong>{$p}</strong> ";
			else echo "<a href='?".$this->pageVar."={$p}'>{$p}</a> ";
		}
		
		//Show the Next Link
		if($page==ceil(count($this->items)/$this->resultsPerPage)) echo "<span>Next &raquo;</span><br>";
		else echo "<a href='?".$this->pageVar."=".($page+1)."'>Next &raquo;</a><br>";
		
		//End Nav
		echo '</div>'."\n";
	}
	
	/* Get or set the pageVar field */
	public function getPageVar() { return($this->pageVar); }
	public function setPageVar($pageVar) { if(is_string($pageVar) && !$this->paginated) $this->pageVar = $pageVar; }
	
	/* Get or set the resultsPerPage field */
	public function getResultsPerPage() { return($this->resultsPerPage); }
	public function setResultsPerPage($resultsPerPage) 
	{
		//If the arg is a valid #, set the new value
		if(is_int($resultsPerPage) && $resultsPerPage>0 && !$this->paginated) $this->resultsPerPage = $resultsPerPage; 
	}
	
	private function isValidPageVar($pageVar)
	{
		//Return valid if arg is string and is not empty
		return(!empty($pageVar) && is_string($pageVar));
	}
	
	private function isValidResultsPerPage($resultsPerPage)
	{
		//Return valid if arg is a positive integer
		return(is_int($resultsPerPage) || $resultsPerPage>0);
	}
}

class paginationData {
	private $program;
	private $channel;
	private $airdate;
	private $exiration;
	private $episode;
	private $setReminder;
		   
	public function __construct($program, $channel, $airdate, $expiration, $episode, $setReminder)
	{
		$this->program = $program;
		$this->channel = $channel;
	  $this->airdate = strtotime($airdate);
		$this->expiration = $expiration;
		$this->episode = $episode;
		$this->setReminder = $setReminder;
	}
	
	//This function shows the data
	public function display()
	{
		if(date('Y-m-d') == date('Y-m-d', $this->airdate)) $dateFormat = 'g:ia';
    	elseif(date('Y') == date('Y', $this->airdate)) $dateFormat = 'F jS - g:ia';
		else $dateFormat = 'F jS, Y - g:ia';
	
		echo '<tr>'."\n".
			 '	<td><strong>'.$this->program.'</strong></td>'."\n".
			 '	<td>showing on '.$this->channel.'</td>'."\n".
    		 '	<td>'.date($dateFormat, $this->airdate).'</td>'."\n".
			 '	<td>'.$this->episode.'</td>'."\n".
			 '	<td>'.$this->setReminder.'</td>'."\n".
			 '</tr>'."\n";
	}
}
?>

It's still having some problems with records, e.g. not showing a programme that airs at 1.25pm GMT UK time today.

OK, here's the code now with the changes:

<?php
/***********************************
 * PhpMyCoder Paginator            *
 * Created By PhpMyCoder           *
 * 2010 PhpMyCoder                 *
 * ------------------------------- *
 * You may use this code as long   *
 * as this notice stays intact and *
 * the proper credit is given to   *
 * the author.                     *
 ***********************************/
 
class pmcPagination {
	private $pageVar = "page";     //$_GET variable to get page # from
	private $items = array();      //Array of items to paginate
	private $resultsPerPage = 10;  //Results to be displayed per page
	private $paginated = false;    //Has the paginate() function been called?
	
	public function __construct($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Set pageVar if arg is valid
		if($this->isValidPageVar($pageVar)) $this->pageVar = $pageVar;
		
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		
		//Add items passed
		$this->add($items);
	}
	
	public function add($items)
	{
		//If the item is null, exit function
		if(is_null($items)) return;
				   
		//If arg is not an array, make it one
		if(!is_array($items)) $items = array($items);
		
		//Cycle through items passed
		foreach($items as $item)
		{
			//Add them to the $items array if they are valid
			if($item instanceof paginationData) $this->items[] = $item;	
		}
	}
	
// 	public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
// 	{
// 		//Prevent set function form changing values
// 		$this->paginated = true;
// 		
// 		//Set pageVar if arg is valid
// 		if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
// 		//Set parVar to previous value
// 		else $pageVar = $this->pageVar;
// 		
// 		//Set resultsPerPage if arg is valid
// 		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
// 		//Set resultsPerPage to previous value
// 		else $resultsPerPage = $this->resultsPerPage;
// 		
// 		//Add any extra items
// 		$this->add($items);
// 		
// 		//Get Page #, Staring Result #, and Ending Result #
// 		if(isset($_GET[$pageVar]) && $_GET[$pageVar] > 0) $page = $_GET[$pageVar];
// 		else $page = 1;
// 		$result = ($page - 1) * $resultsPerPage + 1;
// 		$max = $result + $resultsPerPage;
// 		if($max >= count($this->items)) $max = count($this->items);
// 		
// 		//Are there results?
// 		if($result<count($this->items))
// 		{
// 			//Cycle through results on current page
// 			for(;$result<$max;$result++)
// 		 	{
// 				//Show the result 
// 				$this->items[$result]->display();
// 		 	}
// 		}
// 		//Display a "no results" message
// 		else echo "<strong>No Results found on this page.</strong>";
// 	}
print_r($this->items);	
	public function navigation()
	{
		//Get Pag #
		if(isset($_GET[$this->pageVar]) && $_GET[$this->pageVar] > 0) $page = $_GET[$this->pageVar];
		else $page = 1;
		
		//Start Nav
		echo '<div id="nav">'."\n";
		
		//Show the Previous Link
		if($page==1) echo "<span>&laquo; Previous</span> ";
		else echo "<a href='?".$this->pageVar."=".($page-1)."'>&laquo; Previous</a> ";
		
		//Show the Number Links
		for($p=1;$p<=ceil(count($this->items)/$this->resultsPerPage);$p++)
		{
			if($p==$page) echo "<strong>{$p}</strong> ";
			else echo "<a href='?".$this->pageVar."={$p}'>{$p}</a> ";
		}
		
		//Show the Next Link
		if($page==ceil(count($this->items)/$this->resultsPerPage)) echo "<span>Next &raquo;</span><br>";
		else echo "<a href='?".$this->pageVar."=".($page+1)."'>Next &raquo;</a><br>";
		
		//End Nav
		echo '</div>'."\n";
	}
	
	/* Get or set the pageVar field */
	public function getPageVar() { return($this->pageVar); }
	public function setPageVar($pageVar) { if(is_string($pageVar) && !$this->paginated) $this->pageVar = $pageVar; }
	
	/* Get or set the resultsPerPage field */
	public function getResultsPerPage() { return($this->resultsPerPage); }
	public function setResultsPerPage($resultsPerPage) 
	{
		//If the arg is a valid #, set the new value
		if(is_int($resultsPerPage) && $resultsPerPage>0 && !$this->paginated) $this->resultsPerPage = $resultsPerPage; 
	}
	
	private function isValidPageVar($pageVar)
	{
		//Return valid if arg is string and is not empty
		return(!empty($pageVar) && is_string($pageVar));
	}
	
	private function isValidResultsPerPage($resultsPerPage)
	{
		//Return valid if arg is a positive integer
		return(is_int($resultsPerPage) || $resultsPerPage>0);
	}
}

class paginationData {
	private $program;
	private $channel;
	private $airdate;
	private $exiration;
	private $episode;
	private $setReminder;
		   
	public function __construct($program, $channel, $airdate, $expiration, $episode, $setReminder)
	{
		$this->program = $program;
		$this->channel = $channel;
	  $this->airdate = strtotime($airdate);
		$this->expiration = $expiration;
		$this->episode = $episode;
		$this->setReminder = $setReminder;
	}
	
	//This function shows the data
	public function display()
	{
		if(date('Y-m-d') == date('Y-m-d', $this->airdate)) $dateFormat = 'g:ia';
    	elseif(date('Y') == date('Y', $this->airdate)) $dateFormat = 'F jS - g:ia';
		else $dateFormat = 'F jS, Y - g:ia';
	
		echo '<tr>'."\n".
			 '	<td><strong>'.$this->program.'</strong></td>'."\n".
			 '	<td>showing on '.$this->channel.'</td>'."\n".
    		 '	<td>'.date($dateFormat, $this->airdate).'</td>'."\n".
			 '	<td>'.$this->episode.'</td>'."\n".
			 '	<td>'.$this->setReminder.'</td>'."\n".
			 '</tr>'."\n";
	}
}
?>

It needs to be this:

<?php
/***********************************
 * PhpMyCoder Paginator            *
 * Created By PhpMyCoder           *
 * 2010 PhpMyCoder                 *
 * ------------------------------- *
 * You may use this code as long   *
 * as this notice stays intact and *
 * the proper credit is given to   *
 * the author.                     *
 ***********************************/
 
class pmcPagination {
	private $pageVar = "page";     //$_GET variable to get page # from
	private $items = array();      //Array of items to paginate
	private $resultsPerPage = 10;  //Results to be displayed per page
	private $paginated = false;    //Has the paginate() function been called?
	
	public function __construct($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Set pageVar if arg is valid
		if($this->isValidPageVar($pageVar)) $this->pageVar = $pageVar;
		
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		
		//Add items passed
		$this->add($items);
	}
	
	public function add($items)
	{
		//If the item is null, exit function
		if(is_null($items)) return;
				   
		//If arg is not an array, make it one
		if(!is_array($items)) $items = array($items);
		
		//Cycle through items passed
		foreach($items as $item)
		{
			//Add them to the $items array if they are valid
			if($item instanceof paginationData) $this->items[] = $item;	
		}
	}
	
 	public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
 	{
		print_r($this->items);
		/*
 		//Prevent set function form changing values
 		$this->paginated = true;
 		
 		//Set pageVar if arg is valid
 		if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
 		//Set parVar to previous value
 		else $pageVar = $this->pageVar;
 		
 		//Set resultsPerPage if arg is valid
 		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
 		//Set resultsPerPage to previous value
 		else $resultsPerPage = $this->resultsPerPage;
 		
 		//Add any extra items
 		$this->add($items);
 		
 		//Get Page #, Staring Result #, and Ending Result #
 		if(isset($_GET[$pageVar]) && $_GET[$pageVar] > 0) $page = $_GET[$pageVar];
 		else $page = 1;
 		$result = ($page - 1) * $resultsPerPage + 1;
 		$max = $result + $resultsPerPage;
 		if($max >= count($this->items)) $max = count($this->items);
 		
 		//Are there results?
 		if($result<count($this->items))
 		{
 			//Cycle through results on current page
 			for(;$result<$max;$result++)
 		 	{
 				//Show the result 
 				$this->items[$result]->display();
 		 	}
 		}
 		//Display a "no results" message
 		else echo "<strong>No Results found on this page.</strong>";
		*/
 	}	
	public function navigation()
	{
		//Get Pag #
		if(isset($_GET[$this->pageVar]) && $_GET[$this->pageVar] > 0) $page = $_GET[$this->pageVar];
		else $page = 1;
		
		//Start Nav
		echo '<div id="nav">'."\n";
		
		//Show the Previous Link
		if($page==1) echo "<span>&laquo; Previous</span> ";
		else echo "<a href='?".$this->pageVar."=".($page-1)."'>&laquo; Previous</a> ";
		
		//Show the Number Links
		for($p=1;$p<=ceil(count($this->items)/$this->resultsPerPage);$p++)
		{
			if($p==$page) echo "<strong>{$p}</strong> ";
			else echo "<a href='?".$this->pageVar."={$p}'>{$p}</a> ";
		}
		
		//Show the Next Link
		if($page==ceil(count($this->items)/$this->resultsPerPage)) echo "<span>Next &raquo;</span><br>";
		else echo "<a href='?".$this->pageVar."=".($page+1)."'>Next &raquo;</a><br>";
		
		//End Nav
		echo '</div>'."\n";
	}
	
	/* Get or set the pageVar field */
	public function getPageVar() { return($this->pageVar); }
	public function setPageVar($pageVar) { if(is_string($pageVar) && !$this->paginated) $this->pageVar = $pageVar; }
	
	/* Get or set the resultsPerPage field */
	public function getResultsPerPage() { return($this->resultsPerPage); }
	public function setResultsPerPage($resultsPerPage) 
	{
		//If the arg is a valid #, set the new value
		if(is_int($resultsPerPage) && $resultsPerPage>0 && !$this->paginated) $this->resultsPerPage = $resultsPerPage; 
	}
	
	private function isValidPageVar($pageVar)
	{
		//Return valid if arg is string and is not empty
		return(!empty($pageVar) && is_string($pageVar));
	}
	
	private function isValidResultsPerPage($resultsPerPage)
	{
		//Return valid if arg is a positive integer
		return(is_int($resultsPerPage) || $resultsPerPage>0);
	}
}

class paginationData {
	private $program;
	private $channel;
	private $airdate;
	private $exiration;
	private $episode;
	private $setReminder;
		   
	public function __construct($program, $channel, $airdate, $expiration, $episode, $setReminder)
	{
		$this->program = $program;
		$this->channel = $channel;
	  $this->airdate = strtotime($airdate);
		$this->expiration = $expiration;
		$this->episode = $episode;
		$this->setReminder = $setReminder;
	}
	
	//This function shows the data
	public function display()
	{
		if(date('Y-m-d') == date('Y-m-d', $this->airdate)) $dateFormat = 'g:ia';
    	elseif(date('Y') == date('Y', $this->airdate)) $dateFormat = 'F jS - g:ia';
		else $dateFormat = 'F jS, Y - g:ia';
	
		echo '<tr>'."\n".
			 '	<td><strong>'.$this->program.'</strong></td>'."\n".
			 '	<td>showing on '.$this->channel.'</td>'."\n".
    		 '	<td>'.date($dateFormat, $this->airdate).'</td>'."\n".
			 '	<td>'.$this->episode.'</td>'."\n".
			 '	<td>'.$this->setReminder.'</td>'."\n".
			 '</tr>'."\n";
	}
}
?>

I've made those changes as you suggested, got Array() as the result.

Hi,
I think you can do this using Mysql LIMIT in the individual pages..
But before that you need to know how many pages there will be...
for that a mysql count() query will be sufficient....

But I like the Javascript paging ... Have a look at
http://www.kvkbarpeta.com/?q=training.
Use a bigger time period to get the paging....

I have developed this using a try and error method... but it is working well...

If you like this , helping you will be my pleasure.

Garth

I have made another copy of this script in localhost, my own server, in another directory and decided to try this query in demo.php:

$result = mysql_query("SELECT * FROM episodes LEFT JOIN episodes1 ON episodes.info = episodes1.airdate");

How would I get the script to work with queries like that?
(is it even a good idea?)

Well then try this. And yes it will still work. You just have to do is change the way the data is added to the class. Check the readme file for more (It should be similar though, what does your demo query return?).

Try this with the old query:

<?php
/***********************************
 * PhpMyCoder Paginator            *
 * Created By PhpMyCoder           *
 * 2010 PhpMyCoder                 *
 * ------------------------------- *
 * You may use this code as long   *
 * as this notice stays intact and *
 * the proper credit is given to   *
 * the author.                     *
 ***********************************/
 
class pmcPagination {
	private $pageVar = "page";     //$_GET variable to get page # from
	private $items = array();      //Array of items to paginate
	private $resultsPerPage = 10;  //Results to be displayed per page
	private $paginated = false;    //Has the paginate() function been called?
	
	public function __construct($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Set pageVar if arg is valid
		if($this->isValidPageVar($pageVar)) $this->pageVar = $pageVar;
		
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		
		//Add items passed
		$this->add($items);
	}
	
	public function add($items)
	{
		//If the item is null, exit function
		if(is_null($items)) return;
				   
		//If arg is not an array, make it one
		if(!is_array($items)) $items = array($items);
		
		//Cycle through items passed
		foreach($items as $item)
		{
			//Add them to the $items array if they are valid
			if($item instanceof paginationData) $this->items[] = $item;	
		}
	}
	
 	public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
 	{
 		//Prevent set function form changing values
 		$this->paginated = true;
 		
 		//Set pageVar if arg is valid
 		if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
 		//Set parVar to previous value
 		else $pageVar = $this->pageVar;
 		
 		//Set resultsPerPage if arg is valid
 		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
 		//Set resultsPerPage to previous value
 		else $resultsPerPage = $this->resultsPerPage;
 		
 		//Add any extra items
 		$this->add($items);

		print_r($this->items);
		/*
 		//Get Page #, Staring Result #, and Ending Result #
 		if(isset($_GET[$pageVar]) && $_GET[$pageVar] > 0) $page = $_GET[$pageVar];
 		else $page = 1;
 		$result = ($page - 1) * $resultsPerPage + 1;
 		$max = $result + $resultsPerPage;
 		if($max >= count($this->items)) $max = count($this->items);
 		
 		//Are there results?
 		if($result<count($this->items))
 		{
 			//Cycle through results on current page
 			for(;$result<$max;$result++)
 		 	{
 				//Show the result 
 				$this->items[$result]->display();
 		 	}
 		}
 		//Display a "no results" message
 		else echo "<strong>No Results found on this page.</strong>";
		*/
 	}	
	public function navigation()
	{
		//Get Pag #
		if(isset($_GET[$this->pageVar]) && $_GET[$this->pageVar] > 0) $page = $_GET[$this->pageVar];
		else $page = 1;
		
		//Start Nav
		echo '<div id="nav">'."\n";
		
		//Show the Previous Link
		if($page==1) echo "<span>&laquo; Previous</span> ";
		else echo "<a href='?".$this->pageVar."=".($page-1)."'>&laquo; Previous</a> ";
		
		//Show the Number Links
		for($p=1;$p<=ceil(count($this->items)/$this->resultsPerPage);$p++)
		{
			if($p==$page) echo "<strong>{$p}</strong> ";
			else echo "<a href='?".$this->pageVar."={$p}'>{$p}</a> ";
		}
		
		//Show the Next Link
		if($page==ceil(count($this->items)/$this->resultsPerPage)) echo "<span>Next &raquo;</span><br>";
		else echo "<a href='?".$this->pageVar."=".($page+1)."'>Next &raquo;</a><br>";
		
		//End Nav
		echo '</div>'."\n";
	}
	
	/* Get or set the pageVar field */
	public function getPageVar() { return($this->pageVar); }
	public function setPageVar($pageVar) { if(is_string($pageVar) && !$this->paginated) $this->pageVar = $pageVar; }
	
	/* Get or set the resultsPerPage field */
	public function getResultsPerPage() { return($this->resultsPerPage); }
	public function setResultsPerPage($resultsPerPage) 
	{
		//If the arg is a valid #, set the new value
		if(is_int($resultsPerPage) && $resultsPerPage>0 && !$this->paginated) $this->resultsPerPage = $resultsPerPage; 
	}
	
	private function isValidPageVar($pageVar)
	{
		//Return valid if arg is string and is not empty
		return(!empty($pageVar) && is_string($pageVar));
	}
	
	private function isValidResultsPerPage($resultsPerPage)
	{
		//Return valid if arg is a positive integer
		return(is_int($resultsPerPage) || $resultsPerPage>0);
	}
}

class paginationData {
	private $program;
	private $channel;
	private $airdate;
	private $exiration;
	private $episode;
	private $setReminder;
		   
	public function __construct($program, $channel, $airdate, $expiration, $episode, $setReminder)
	{
		$this->program = $program;
		$this->channel = $channel;
	  $this->airdate = strtotime($airdate);
		$this->expiration = $expiration;
		$this->episode = $episode;
		$this->setReminder = $setReminder;
	}
	
	//This function shows the data
	public function display()
	{
		if(date('Y-m-d') == date('Y-m-d', $this->airdate)) $dateFormat = 'g:ia';
    	elseif(date('Y') == date('Y', $this->airdate)) $dateFormat = 'F jS - g:ia';
		else $dateFormat = 'F jS, Y - g:ia';
	
		echo '<tr>'."\n".
			 '	<td><strong>'.$this->program.'</strong></td>'."\n".
			 '	<td>showing on '.$this->channel.'</td>'."\n".
    		 '	<td>'.date($dateFormat, $this->airdate).'</td>'."\n".
			 '	<td>'.$this->episode.'</td>'."\n".
			 '	<td>'.$this->setReminder.'</td>'."\n".
			 '</tr>'."\n";
	}
}
?>

This is what the old query returned:

Array ( [0] => paginationData Object ( [program:private] => [channel:private] => [airdate:private] => [exiration:private] => [episode:private] => [setReminder:private] => [expiration] => ) )

with the database results in between the array.

What is exiration? Did you change something in the code? As far as I remember, there were no spelling mistakes in the one I sent to you (I always double check!).

I didn't change anything in the code, and exiration still appears, even though a value is $expiration.

This is your code:

<?php
/***********************************
 * PhpMyCoder Paginator            *
 * Created By PhpMyCoder           *
 * 2010 PhpMyCoder                 *
 * ------------------------------- *
 * You may use this code as long   *
 * as this notice stays intact and *
 * the proper credit is given to   *
 * the author.                     *
 ***********************************/
 
class pmcPagination {
	private $pageVar = "page";     //$_GET variable to get page # from
	private $items = array();      //Array of items to paginate
	private $resultsPerPage = 10;  //Results to be displayed per page
	private $paginated = false;    //Has the paginate() function been called?
	
	public function __construct($resultsPerPage="", $pageVar=0, $items=NULL)
	{
		//Set pageVar if arg is valid
		if($this->isValidPageVar($pageVar)) $this->pageVar = $pageVar;
		
		//Set resultsPerPage if arg is valid
		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
		
		//Add items passed
		$this->add($items);
	}
	
	public function add($items)
	{
		//If the item is null, exit function
		if(is_null($items)) return;
				   
		//If arg is not an array, make it one
		if(!is_array($items)) $items = array($items);
		
		//Cycle through items passed
		foreach($items as $item)
		{
			//Add them to the $items array if they are valid
			if($item instanceof paginationData) $this->items[] = $item;	
		}
	}
	
 	public function paginate($resultsPerPage="", $pageVar=0, $items=NULL)
 	{
 		//Prevent set function form changing values
 		$this->paginated = true;
 		
 		//Set pageVar if arg is valid
 		if($this->isvalidPageVar($pageVar)) $this->pageVar = $pageVar;
 		//Set parVar to previous value
 		else $pageVar = $this->pageVar;
 		
 		//Set resultsPerPage if arg is valid
 		if($this->isValidResultsPerPage($resultsPerPage)) $this->resultsPerPage = $resultsPerPage;
 		//Set resultsPerPage to previous value
 		else $resultsPerPage = $this->resultsPerPage;
 		
 		//Add any extra items
 		$this->add($items);

		print_r($this->items);
		/*
 		//Get Page #, Staring Result #, and Ending Result #
 		if(isset($_GET[$pageVar]) && $_GET[$pageVar] > 0) $page = $_GET[$pageVar];
 		else $page = 1;
 		$result = ($page - 1) * $resultsPerPage + 1;
 		$max = $result + $resultsPerPage;
 		if($max >= count($this->items)) $max = count($this->items);
 		
 		//Are there results?
 		if($result<count($this->items))
 		{
 			//Cycle through results on current page
 			for(;$result<$max;$result++)
 		 	{
 				//Show the result 
 				$this->items[$result]->display();
 		 	}
 		}
 		//Display a "no results" message
 		else echo "<strong>No Results found on this page.</strong>";
		*/
 	}	
	public function navigation()
	{
		//Get Pag #
		if(isset($_GET[$this->pageVar]) && $_GET[$this->pageVar] > 0) $page = $_GET[$this->pageVar];
		else $page = 1;
		
		//Start Nav
		echo '<div id="nav">'."\n";
		
		//Show the Previous Link
		if($page==1) echo "<span>&laquo; Previous</span> ";
		else echo "<a href='?".$this->pageVar."=".($page-1)."'>&laquo; Previous</a> ";
		
		//Show the Number Links
		for($p=1;$p<=ceil(count($this->items)/$this->resultsPerPage);$p++)
		{
			if($p==$page) echo "<strong>{$p}</strong> ";
			else echo "<a href='?".$this->pageVar."={$p}'>{$p}</a> ";
		}
		
		//Show the Next Link
		if($page==ceil(count($this->items)/$this->resultsPerPage)) echo "<span>Next &raquo;</span><br>";
		else echo "<a href='?".$this->pageVar."=".($page+1)."'>Next &raquo;</a><br>";
		
		//End Nav
		echo '</div>'."\n";
	}
	
	/* Get or set the pageVar field */
	public function getPageVar() { return($this->pageVar); }
	public function setPageVar($pageVar) { if(is_string($pageVar) && !$this->paginated) $this->pageVar = $pageVar; }
	
	/* Get or set the resultsPerPage field */
	public function getResultsPerPage() { return($this->resultsPerPage); }
	public function setResultsPerPage($resultsPerPage) 
	{
		//If the arg is a valid #, set the new value
		if(is_int($resultsPerPage) && $resultsPerPage>0 && !$this->paginated) $this->resultsPerPage = $resultsPerPage; 
	}
	
	private function isValidPageVar($pageVar)
	{
		//Return valid if arg is string and is not empty
		return(!empty($pageVar) && is_string($pageVar));
	}
	
	private function isValidResultsPerPage($resultsPerPage)
	{
		//Return valid if arg is a positive integer
		return(is_int($resultsPerPage) || $resultsPerPage>0);
	}
}

class paginationData {
	private $program;
	private $channel;
	private $airdate;
	private $expiration;
	private $episode;
	private $setReminder;
		   
	public function __construct($program, $channel, $airdate, $expiration, $episode, $setReminder)
	{
		$this->program = $program;
		$this->channel = $channel;
	  $this->airdate = strtotime($airdate);
		$this->expiration = $expiration;
		$this->episode = $episode;
		$this->setReminder = $setReminder;
	}
	
	//This function shows the data
	public function display()
	{
		if(date('Y-m-d') == date('Y-m-d', $this->airdate)) $dateFormat = 'g:ia';
    	elseif(date('Y') == date('Y', $this->airdate)) $dateFormat = 'F jS - g:ia';
		else $dateFormat = 'F jS, Y - g:ia';
	
		echo '<tr>'."\n".
			 '	<td><strong>'.$this->program.'</strong></td>'."\n".
			 '	<td>showing on '.$this->channel.'</td>'."\n".
    		 '	<td>'.date($dateFormat, $this->airdate).'</td>'."\n".
			 '	<td>'.$this->episode.'</td>'."\n".
			 '	<td>'.$this->setReminder.'</td>'."\n".
			 '</tr>'."\n";
	}
}
?>

Still... how do I get it to make sure the database doesn't need me to duplicate records?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.