I created code for my TV guide web site, as mentioned in a previous thread (http://www.daniweb.com/forums/thread247517.html).
I solved the problem, in the code below.
This is the new code, which works well:
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","PASSWORD");
//select which database you want to edit
mysql_select_db("tvguide");
// Select only results for today and future
$result = mysql_query("SELECT * FROM epdata WHERE airdate >= CURDATE() ORDER BY airdate ASC LIMIT 20;");
while($r = mysql_fetch_array($result)) {
$programme = $r["programme"];
$channel = $r["channel"];
$airdate = strtotime($r['airdate']);
$episode = $r["episode"];
$setreminder = $r["setreminder"];
$now = time();
if(date('Y-m-d') == date('Y-m-d', $airdate)) {
// Same date, show only time
$dateFormat = 'g:ia';
} elseif(date('Y') == date('Y', $airdate)) {
// Same year, show date without year
$dateFormat = 'F jS - g:ia';
} else {
// Other cases, show full date
$dateFormat = 'F jS, Y - g:ia';
}
$airdateFormatted = date($dateFormat, $airdate);
echo "<tr><td><b>$programme</b></td><td>showing on $channel</td>";
echo "<td>$airdateFormatted</td><td>$episode</td><td>$setreminder</td></tr>";
}
?>
However, once the date has elapsed it hides the records, but not once the time has passed - the records still show.
To give an example, if I have a programme that airs at 6:30pm, I want it to show the record, but then hide it once the programme has aired (in this case in 30 minutes), or another example - a programme that starts at 9:00pm and finishes at 10:00pm.
I haven't found any scripts in PHP that work for this, so if anyone has any advice on how to do this it would be appreciated!
Thanks for your help last time!