You are here:  » nested loop


nested loop

Submitted by badger on Tue, 2007-01-09 19:36 in

Hi David,

I am trying to create a directory of links using mp but the nested loop doesnt seem to work. Only loops once.

Here is an example of a directory

Arts <---------------------------- root level
Movies, Television, Music... <---- sub categories
Business <--------------------------- root level
Jobs, Real Estate, Investing... <---- sub categories
Computers <-------------------------- root level
Internet, Software, Hardware...<---- sub categories

First loop returns all results where parent=root (arts, business, computers)
Then a nested loop will return the sub categories

Maybe you could look at me code and spot something.

<?php
  
require("MagicParser.php");
  function 
mySubCategories($link)
  {
    
//print_r($link);
    
if (trim($link["PARENT"]) == "rings")
    {
      print 
"<a href='".$link["URL"]."' style='font-size:12px;'>".$link["NAME"]."</a>&nbsp;";
    }
  }
  function 
myRecordHandler($link)
  {
    
//print_r($link);
    
if (trim($link["PARENT"]) == "root")
    {
      print 
"<a href='".$link["URL"]."' style='font-size:20px;'>".$link["NAME"]."</a><br>";
      
MagicParser_parse("MagicParserTest.xml","mySubCategories","xml|LINKS/LINK/");
    }
  }
  
MagicParser_parse("MagicParserTest.xml","myRecordHandler","xml|LINKS/LINK/");
?>

thanks

Submitted by support on Tue, 2007-01-09 19:39

Hi,

Could you possibly send me a sample of the XML and i'll take a look. Reply to your reg code or forum registration email is the easiest way...

Cheers,
David.