Hi guys, i am trying to set up a TV guide just like the Yahoo TV guide. {link saved}
this is my TV guide
{link saved}
I am trying to figure out how to do the html table.
I see the problem as
if i have a show starting at 3:00pm - which in the DB it is 15:00 then and it finish at 3:30pm - 15:30
how do show it as a 30min program so it finishes in between 3:00 and 4:00
and then the second program starts at 3:30 and finish at 5:00 how would i show that.
i see i cant really use tables? i guess i would have to use divs?
if anyone can help that would help.


Hi Russell, Yes - I would
Hi Russell,
Yes - I would use divs - and perhaps look at making the width of the DIV (via the style attribute) a function of the programme length. For example, if you decide on a width of 2 pixels per minute, then you could render a div as follows (where $length is the programme length in minutes):
print "<div style='width:".($minutes*2)."px;'>";// output programme information
print "</div>";
Cheers!
David.
Thanks David, How would i
Thanks David,
How would i turn 15:30 into minutes?
Hi Russell, To get the
Hi Russell,
To get the length of a programme in minutes, I would use PHP's strtotime() function on the start and end times, subtract start from end, and then divide by 60 as strtotime() returns time values in seconds. For example...
<?php$start = "2009-04-29 15:30:00";
$end = "2009-04-29 16:00:00";
$minutes = (strtotime($end) - strtotime($start)) / 60;
?>
Hope this helps!
Cheers,
David.
Hey David, I have done what
Hey David,
I have done what you said above however i am getting different minutes for shows of the same length .
2009-04-30 04:00:00 - 2009-04-30 04:30:00
20684670
2009-04-30 04:30:00 - 2009-04-30 05:30:00
20684730
this is the PHP code
<?php
$today = date("Y-m-d");
$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
$tvdate = date("Y-m-d", $tomorrow);
require("MagicParser.php");
function myRecordHandler($record)
{
$time = $record["PROGRAMME-START"];
list($y,$m,$d,$h,$j,$s) = sscanf($time,"%4s%2s%2s%2s%2s%2s");
$time = strtotime("$y-$m-$d $h:$j:$s");
// convert to Eastern Australia (+10 hours)
$time += 00000;
$time = date("Y-m-d H:i:s",$time);
print $time;
echo " - ";
$time = $record["PROGRAMME-STOP"];
list($y,$m,$d,$h,$j,$s) = sscanf($time,"%4s%2s%2s%2s%2s%2s");
$time = strtotime("$y-$m-$d $h:$j:$s");
// convert to Eastern Australia (+10 hours)
$time += 00000;
$endtime = date("Y-m-d H:i:s",$time);
print $endtime;
echo "<br/>";
$minutes = (strtotime($endtime) - strtotime($time)) / 60;
print $minutes;
echo "<br/>".$record["TITLE"]."<br/>".$record["DESC"]."<br/><BR/>";
}
$url = "http://www.oztivo.net/xmltv/One_".$tvdate.".xml.gz";
$fp = gzopen($url,"r");
if (!$fp) die("Could not open ".$url);
while(!gzeof($fp)) $xml .= gzread($fp,1024);
gzclose($fp);
MagicParser_parse("string://".$xml,"myRecordHandler","xml|TV/PROGRAMME/");
?>
Hi Russell, The programmes
Hi Russell,
The programmes do appear to be different lengths (the first one is 30 minutes, the second one is 60 minutes) - but I think the $time variable is getting overwritten in your code... try this so that you have both $starttime and $endtime
$time = $record["PROGRAMME-START"];
list($y,$m,$d,$h,$j,$s) = sscanf($time,"%4s%2s%2s%2s%2s%2s");
$time = strtotime("$y-$m-$d $h:$j:$s");
// convert to Eastern Australia (+10 hours)
$time += 00000;
$starttime = date("Y-m-d H:i:s",$time);
print $starttime;
echo " - ";
$time = $record["PROGRAMME-STOP"];
list($y,$m,$d,$h,$j,$s) = sscanf($time,"%4s%2s%2s%2s%2s%2s");
$time = strtotime("$y-$m-$d $h:$j:$s");
// convert to Eastern Australia (+10 hours)
$time += 00000;
$endtime = date("Y-m-d H:i:s",$time);
print $endtime;
echo "<br/>";
$minutes = (strtotime($endtime) - strtotime($starttime)) / 60;
print $minutes;
Hope this helps!
Cheers,
David.
That helps alot. I am just
That helps alot.
I am just making the MySQL db for it. Still have a few things i have to work out. like how do i get the output of the MySQL like the TV guide @ Yahoo.