recursive function not returning anything..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



   function recursePathLookup($CatID, $Path = array()) {

      //Get the catid for this subcat

      $sql = "SELECT SubCategoryID, Name FROM categories WHERE CategoryID =
'".$CatID."'";

      $query = mysql_query($sql);

      if(mysql_num_rows($query) == 1) {

         $data = mysql_fetch_array($query);

         $Path[] = $data["Name"];

         recursePathLookup($data["SubCategoryID"], $Path);

      } else {

         //print_r($Path);

         return $Path;

      }

   }

 

   print_r(recursePathLookup(2));

 

Any ideas why when I uncomment the //print_r($Path) inside the function it
prints the value fine, but when I try to return the value and print it
outside the function I get nothing?

Thanks,

Nate


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux