You are here:  » Show one or two records


Show one or two records

Submitted by aslater on Wed, 2009-06-10 13:39 in

Hello is it possible to just show the first couple of records only from an xml file?

Submitted by support on Wed, 2009-06-10 13:44

Hi,

Sure - you can stop the parser by returning TRUE from your myRecordHandler function; so all you need to do is keep a global counter, increment the counter for each record and then return TRUE if has reached the number you wish to display. For example:

<?php
  
function myRecordHandler($record)
  {
    global 
$counter;
    
// display $record as normal
    
$counter++;
    if (
$counter == 2) return TRUE// stop after 2 records
  
}
?>

Hope this helps!
Cheers,
David.

Submitted by aslater on Wed, 2009-06-10 14:41

Thanks that works!