You are here:  » Need the date of the record -1 loop in the current loop


Need the date of the record -1 loop in the current loop

Submitted by cosmicadi on Thu, 2007-03-22 13:37 in

Hi there,

i need to get the date of a record called X-1
when i parse the record X.

the code looks like

<?php
function myRecordHandler($record)
{
   
$date              $record["AUSSTRAHLUNG/DATUM"];
   
$date              explode(".",$date);
   
$date2             $date[2]."-".$date[1]."-".$date[0];
   
$start             $record["AUSSTRAHLUNG/BEGINNENDEUHRZEIT"];
   
$start             substr($start,0,5);
   
$start .=":00";
   
$date2 .=$start";
   
$start=explode(":",$start);
   
$start_temp $start[0]."".$start[1];
   if (((
$startzeit_alt $start_temp)&&$startzeit_alt) || $next_day){ $unix_timestamp =
    
mktime($start[0],$start[1],$start[2],$date[1],$date[0]+1,$date[2]);
   
$next_day=true;
   }
   else{ 
$unix_timestamp mktime($start[0],$start[1],$start[2],$date[1],$date[0],$date[2]);}
   
$startzeit_alt $start_temp;
   
INSERT INTO etc...
}
$basedir .="xml/premiere/";
$handle opendir($basedir);
while (
$filename readdir($handle)) {
 
$path =$basedir.$filename;
 
MagicParser_parse("$path","myRecordHandler","xml|PROGRAMMLISTING/EVENT/");
}
?>

But the startzeit_alt variable is '';
How can i get the startzeit_alt variabel into the call of myRecordHandler

Hope to get an answer thx.

Adrian

Submitted by support on Thu, 2007-03-22 13:46

Hi Adrian,

I think it is just because you have not declared $startzeit_alt as global. Add the global declaration on first line of your record handler function as follows:

<?php
function myRecordHandler($record)
{
    global 
$startzeit_alt;
    ...
?>

That should do the trick!
Cheers,
David.

Submitted by cosmicadi on Thu, 2007-03-22 14:18

thx a lot... ähm.. embarrassing ...