My code and yours, regarding the date, are exactly the same (Except for the $now = time(); which is unnecessary). To suppress the errors, you can use:

error_reporting(0);

How about try:

if((int)date('Ymd') === (int)date('Ymd', $this->airdate)) $dateFormat = 'g:ia';
elseif((int)date('Y') === (int)date('Y', $this->airdate)) $dateFormat = 'F jS - g:ia';
else $dateFormat = 'F jS, Y - g:ia';

OK, so I've now got it on my development site here:
http://phpsandbox162.v3host.be/demo.php

Disclaimer: This is not advertising for a site - it is a site for testing/development of PHP scripts, so keeps within http://www.daniweb.com/forums/announcement17-37.html

The script almost works - I made the changes mentioned above - but it's still showing January 1st, 1970, as seen above.

What should I do to fix this error so it retrieves the proper date/time from the database?

Thank you for all your help so far!

Sorry to bring an old thread back up, but I'm still getting the date/time as January 1st, 1970 - despite using the code above.

Should I post my full coding here?

I suspect you are still using the same code I gave you some time ago. If so, The problem is with the date function. Maybe you could try echoing (or vardumping) the UNIX timstamp you are feeding to it and check and see if the number is right. You can convert that number at the Online Unix Timestamp Converter.

I think it's maybe because in my database I had the date stored as DATETIME... is that wrong?

Oh ok! Yeah that's your problem! Try using TIMESTAMP instead.

Yeah, you need the TIMESTAMP format because it stores the time as a large int containing the time in seconds since the Unix Epoch. This is what the date() function accepts (You can convert, but it would just be easier to change your MySQL DB row type to TIMESTAMP).

OK, I've changed it... still got January 1st, 1970 error...

Wow! This has been very problematic! Sorry about all of this (It should be much easier than this)! I've, though, tested the code on my personal server again and it works fine for me (I used the time function and subtracted a random interger for random dates). Can you post some of the values of your airdate field in the episodes table? The problem has to be there!

Also, while re-testing, I found a little error in my code:
Line 68 of pmcPagination.php should be

$result = ($page - 1) * $resultsPerPage;

This shouldn't fix the problem, but it should be corrected. :)

OK, this is from my PHPMyadmin as you requested:

airdate timestamp ON UPDATE CURRENT_TIMESTAMP No CURRENT_TIMESTAMP
expiration timestamp No 0000-00-00 00:00:00

"No" refers to not being null in phpmyadmin.

Oh, I was a little unclear. I want some of the actual values from the table. For example, let's say there was an episode called Pilot. I'm looking for the number in the airdate column of the row with the episode name of pilot. Basically, I want to make sure that the airdate field isn't invalid. To simplify things, try running this script (With the proper MySQL login credentials provided):

mysql_connect("HOST", "USER", "PASSWORD");
mysql_select_db("housemdepisodes");
$result = mysql_query("SELECT airdate FROM epdata");
$count = 0;
while($arr = mysql_fetch_array($result)) 
{
  echo $count.'. '.$arr['airdate'].'<br>';
  $count++;
}

After you run this script on your server report back with what the script outputs.

OK, here's the results (apologies for the extra length):

0. 2010-02-05 00:25:00
1. 2010-02-05 11:25:00
2. 2010-02-05 21:00:00
3. 2010-02-06 00:35:00
4. 2010-02-06 11:25:00
5. 2010-02-06 16:20:00
6. 2010-02-06 16:55:00
7. 2010-02-06 17:45:00
8. 2010-02-06 18:35:00
9. 2010-02-06 22:50:00
10. 2010-02-07 00:25:00
11. 2010-02-07 11:35:00
12. 2010-02-07 19:30:00
13. 2010-02-08 00:25:00
14. 2010-02-08 11:35:00
15. 2010-02-08 13:25:00
16. 2010-02-08 13:55:00
17. 2010-02-08 16:05:00
18. 2010-02-09 01:35:00
19. 2010-02-09 09:25:00
20. 2010-02-09 10:15:00
21. 2010-02-09 13:30:00
22. 2010-02-09 16:00:00
23. 2010-02-09 19:25:00
24. 2010-02-10 00:25:00
25. 2010-02-10 09:25:00
26. 2010-02-10 10:15:00
27. 2010-02-10 13:55:00
28. 2010-02-11 21:38:04
29. 2010-02-13 00:00:00
30. 2010-02-14 11:25:00
31. 2010-02-14 11:55:00
32. 2010-02-14 14:25:00
33. 2010-02-14 16:00:00
34. 2010-02-15 00:25:00
35. 2010-02-15 17:45:00
36. 2010-02-16 09:25:00
37. 2010-02-16 10:00:00
38. 2010-02-16 13:30:00
39. 2010-02-16 14:00:00
40. 2010-02-16 16:05:00
41. 2010-02-17 09:25:00
42. 2010-02-17 10:00:00
43. 2010-02-17 13:25:00
44. 2010-02-17 13:55:00
45. 2010-02-17 16:05:00
46. 2010-02-17 16:55:00
47. 2010-02-17 21:00:00
48. 2010-02-18 11:25:00
49. 2010-02-18 11:55:00
50. 2010-02-18 13:30:00
51. 2010-02-18 14:45:00
52. 2010-02-18 15:30:00
53. 2010-02-18 16:05:00
54. 2010-02-19 11:35:00
55. 2010-02-19 12:05:00
56. 2010-02-19 14:30:00
57. 2010-02-19 15:00:00
58. 2010-02-19 21:00:00
59. 2010-02-20 00:25:00
60. 2010-02-20 15:11:07
61. 2010-02-20 15:11:07
62. 0000-00-00 00:00:00
63. 2010-02-20 15:11:07
64. 2010-02-20 15:11:07
65. 2010-02-20 15:11:07
66. 2010-02-20 15:11:07
67. 2010-02-20 15:11:07
68. 2010-02-20 15:11:07
69. 2010-02-20 15:11:07
70. 2010-02-20 15:11:07
71. 2010-02-20 15:11:07
72. 2010-02-20 15:11:07
73. 2010-02-20 15:11:07
74. 2010-02-20 15:11:07
75. 2010-02-20 15:11:07
76. 2010-02-20 15:11:07
77. 2010-02-20 15:11:07
78. 2010-02-20 15:11:07
79. 2010-02-20 15:11:07
80. 2010-02-20 15:11:08
81. 2010-02-20 15:11:08
82. 2010-02-20 15:11:08
83. 2010-02-20 15:11:08
84. 2010-02-20 15:11:08
85. 2010-02-20 15:11:08
86. 2010-02-20 15:11:08
87. 2010-02-20 15:11:08
88. 2010-02-20 15:11:08
89. 2010-02-20 15:11:08
90. 2010-02-20 15:08:00
91. 0000-00-00 00:00:00
92. 2010-02-20 15:08:36
93. 2010-02-20 15:08:00
94. 2010-02-20 15:08:00
95. 2010-02-25 00:00:00

This is how I'm trying to get the pagination to look (see the bottom of the table on the page):
http://library.digiguide.com/lib/programmenextshowing/Coronation+Street-7366

Alight then, try changing line 153 of pmcPagination.php to:

$this->airdate = strtotime($airdate);

That should convert the $airdate to the UNIX Epoch time format, which is what the date function requires.

Oh no! Well right about now I don't know what to tell you. I've tried the code on my server, and it works fine. I also just ensured that the date formats you gave me from MySQL formats properly into the UNIX Epoch (which it does). Are you running this site on your own dev server (using XAMPP, WAMP, etc), or do you have it setup on a testing server?

commented: Excellent source of help. Much recommended. +2

It's my own private XAMPP devserver, and I'm not sure how to get this to work properly using the phpMyAdmin - that's where I'm having the problem.

Ok so can you try this:

mysql_connect("HOST", "USER", "PASSWORD");
mysql_select_db("housemdepisodes");
$result = mysql_query("SELECT airdate FROM epdata");
$count = 0;
while($arr = mysql_fetch_array($result)) 
{
  echo $count.'. '.date("m-d-Y h:i:s A", strtotime($arr['airdate'])).'<br>';
  $count++;
}

Then report back with it's results.

OK, here's the code as you requested (note the times have changed due to data being changed here and there):

0. 02-05-2010 12:25:00 AM
1. 02-05-2010 11:25:00 AM
2. 02-05-2010 09:00:00 PM
3. 02-06-2010 12:35:00 AM
4. 02-06-2010 11:25:00 AM
5. 02-06-2010 04:20:00 PM
6. 02-06-2010 04:55:00 PM
7. 02-06-2010 05:45:00 PM
8. 02-06-2010 06:35:00 PM
9. 02-06-2010 10:50:00 PM
10. 02-07-2010 12:25:00 AM
11. 02-07-2010 11:35:00 AM
12. 02-07-2010 07:30:00 PM
13. 02-08-2010 12:25:00 AM
14. 02-08-2010 11:35:00 AM
15. 02-08-2010 01:25:00 PM
16. 02-08-2010 01:55:00 PM
17. 02-08-2010 04:05:00 PM
18. 02-09-2010 01:35:00 AM
19. 02-09-2010 09:25:00 AM
20. 02-09-2010 10:15:00 AM
21. 02-09-2010 01:30:00 PM
22. 02-09-2010 04:00:00 PM
23. 02-09-2010 07:25:00 PM
24. 02-10-2010 12:25:00 AM
25. 02-10-2010 09:25:00 AM
26. 02-10-2010 10:15:00 AM
27. 02-10-2010 01:55:00 PM
28. 02-11-2010 09:38:04 PM
29. 02-13-2010 12:00:00 AM
30. 02-14-2010 11:25:00 AM
31. 02-14-2010 11:55:00 AM
32. 02-14-2010 02:25:00 PM
33. 02-14-2010 04:00:00 PM
34. 02-15-2010 12:25:00 AM
35. 02-15-2010 05:45:00 PM
36. 02-16-2010 09:25:00 AM
37. 02-16-2010 10:00:00 AM
38. 02-16-2010 01:30:00 PM
39. 02-16-2010 02:00:00 PM
40. 02-16-2010 04:05:00 PM
41. 02-17-2010 09:25:00 AM
42. 02-17-2010 10:00:00 AM
43. 02-17-2010 01:25:00 PM
44. 02-17-2010 01:55:00 PM
45. 02-17-2010 04:05:00 PM
46. 02-17-2010 04:55:00 PM
47. 02-17-2010 09:00:00 PM
48. 02-18-2010 11:25:00 AM
49. 02-18-2010 11:55:00 AM
50. 02-18-2010 01:30:00 PM
51. 02-18-2010 02:45:00 PM
52. 02-18-2010 03:30:00 PM
53. 02-18-2010 04:05:00 PM
54. 02-19-2010 11:35:00 AM
55. 02-19-2010 12:05:00 PM
56. 02-19-2010 02:30:00 PM
57. 02-19-2010 03:00:00 PM
58. 02-19-2010 09:00:00 PM
59. 02-20-2010 12:25:00 AM
60. 02-20-2010 11:25:00 AM
61. 02-20-2010 03:30:00 PM
62. 02-20-2010 04:15:00 PM
63. 02-20-2010 05:30:00 PM
64. 02-20-2010 06:30:00 PM
65. 02-21-2010 12:05:00 AM
66. 02-21-2010 11:35:00 AM
67. 02-21-2010 07:30:00 PM
68. 02-22-2010 01:25:00 AM
69. 02-22-2010 11:25:00 AM
70. 02-22-2010 02:25:00 PM
71. 02-22-2010 08:00:00 PM
72. 02-23-2010 09:25:00 AM
73. 02-23-2010 10:15:00 AM
74. 02-23-2010 02:00:00 PM
75. 02-23-2010 02:30:00 PM
76. 02-23-2010 04:00:00 PM
77. 02-24-2010 12:25:00 AM
78. 02-24-2010 09:25:00 AM
79. 02-24-2010 10:15:00 AM
80. 02-24-2010 01:25:00 PM
81. 02-24-2010 01:50:00 PM
82. 02-24-2010 04:00:00 PM
83. 02-25-2010 12:25:00 AM
84. 02-26-2010 11:35:00 AM
85. 02-26-2010 01:35:00 PM
86. 02-26-2010 02:05:00 PM
87. 02-26-2010 07:00:00 PM
88. 02-26-2010 07:30:00 PM
89. 02-25-2010 01:25:00 PM
90. 02-25-2010 04:30:00 PM
91. 02-27-2010 12:20:00 AM
92. 02-27-2010 11:30:00 AM
93. 02-18-2010 07:00:00 PM

This all appears ok. One last thing I want to try: Can you post all of your code. (I know I wrote it, but maybe something was accidentally changed when I sent you the files)

OK, here's the complete code:
pmcpagination.php

<?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";
	}
}
?>

demo.php

<?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.                     *
 ***********************************/
?> 
    	<?php
			//Require the file that contains the required classes
			include("pmcPagination.php");
				
			//PhpMyCoder Paginator
			$paginator = new pmcPagination(10, "page");
			
			//Connect to the database
			mysql_connect("localhost","root","PASSWORD");
			//Select DB
			mysql_select_db("pcadigi");

			//Select only results for today and future
			$result = mysql_query("SELECT * FROM ephouse WHERE expiration >=NOW() ORDER BY expiration ASC");
			
			//You can also add reuslts to paginate here
			while($row = mysql_fetch_array($result))
			{
				$paginator->add(new paginationData($row['programme'],
												   $row['channel'],
												   $row['airdate'],
												   $row['expiration'],
												   $row['episode'],
												   $row['setreminder']));
			}
		?>
        <?php
			//Show the paginated results
			$paginator->paginate ();
		?>
        </table>
        <?php
			//Show the navigation
			$paginator->navigation();						
		?>

(I removed some CSS from that so it would fit in with the site's stylesheet)

and the final page itself, tvguide.php:

<?php 
include("../header.php");
include("demo.php");
include("program-footer1.php");
include("../footer.php");
?>

OK, here's the complete code:
pmcpagination.php

<?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";
	}
}
?>

demo.php

<?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.                     *
 ***********************************/
?> 
    	<?php
			//Require the file that contains the required classes
			include("pmcPagination.php");
				
			//PhpMyCoder Paginator
			$paginator = new pmcPagination(10, "page");
			
			//Connect to the database
			mysql_connect("localhost","root","PASSWORD");
			//Select DB
			mysql_select_db("tvguide");

			//Select only results for today and future
			$result = mysql_query("SELECT * FROM ephouse WHERE expiration >=NOW() ORDER BY expiration ASC");
			
			//You can also add reuslts to paginate here
			while($row = mysql_fetch_array($result))
			{
				$paginator->add(new paginationData($row['programme'],
												   $row['channel'],
												   $row['airdate'],
												   $row['expiration'],
												   $row['episode'],
												   $row['setreminder']));
			}
		?>
        <?php
			//Show the paginated results
			$paginator->paginate ();
		?>
        </table>
        <?php
			//Show the navigation
			$paginator->navigation();						
		?>

(I removed some CSS from that so it would fit in with the site's stylesheet)

and the final page itself, tvguide.php:

<?php 
include("../header.php");
include("demo.php");
include("program-footer1.php");
include("../footer.php");
?>

This almost works... displaying the results nicely now, except for one thing.

Some events don't display - I tried putting two programmes in, one for 6:00pm, one at 6:30pm, both as 18:00:00 and 18:30:00, yet neither seemed to show up - why?

So does the date work now? If so, that's great! Regarding the events: Did you check and see if they are in the database? Also, did you check their expiration date (I remember something about the expiration date being filtered in MySQL). To test this, you can perform the query you use to get the programs and attempt to find the missing ones. If they aren't their, the problem is with you query (I can help with this). If they are there, it's a slight bug in my code (Which I can also fix!).

The basic code is working, but these errors happened:
I have these episodes airing at these times:

House M.D. showing on Channel 5 February 23rd - 9:15am "Episode 1" Set Reminder
House M.D. showing on Channel 5 February 23rd - 10:15am "Episode 1" Set Reminder
House M.D. showing on Channel 5 February 23rd - 2:00pm "test" Set Reminder
House M.D. showing on Channel 5 February 23rd - 3:30pm "test2" Set Reminder
House M.D. showing on Channel 5 February 23rd - 4:30pm "Wilson" Set Reminder
House M.D. showing on Channel 5 February 24th - 12:25am "Wilson" Set Reminder
House M.D. showing on Channel 5 February 24th - 9:25am "Que Sera Sera" Set Reminder
House M.D. showing on Channel 5 February 24th - 1:15pm "Que Sera Sera" Set Reminder

However, the record for the episode that airs at 9:15am does not show at all, and I don't know why - and this is despite the fact it airs on 23-02-2010 (as it is in the database).

(BTW, this is a copy of the database, except with DATETIME as default for airdate and expiration fields).

Did you try the query that I suggested? Are the missing programs appearing in the results of the query?

Yes, the missing programs appear in the query results, so I don't know why this happens...

Just spotted a possible bug... in order to get a record to display, sometimes I have to insert it in twice (occasionally if I'm adding records on the day of the event itself in phpMyAdmin)

Hmm, well if that works, I guess you could use it as a viable workaround, but I still wonder why some of the records don't display. If you would like to investigate this further, try commenting out the paginate function in the pmcPagination class and replace it with:

print_r($this->items);

Then, check if the missing records are outputted (part of the array).

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.