Jump to content

lol


keldorn

Recommended Posts

function build_child($oldID)               // Recursive function to get all of the children...unlimited depth
{

     global $exclude, $depth;
     $tempTree = "";

     $child_query = mysql_query("SELECT * FROM `categories` WHERE parent='{$oldID}' AND depth <=1") or die(mysql_error());

     while( $child = mysql_fetch_array($child_query) )
     {
       
	  
          if ( $child['id'] != $child['parent'] ){
	       
                for ( $c=0;$c<$depth;$c++ ){ 
		   
		      $tempTree .= "<li>{$child['name']}"; 
		    }
		   
               $tempTree .= $child['name'] .   "</li>\n";
               $depth++;         
		   
	 /* Greetings, I heard that you like functions, So I have placed this function inside itself, 
	     thus allowing you to derive while you derive. */  
               $tempTree .= build_child($child['id']); 

		   $depth--;         

               array_push($exclude, $child['id']);              
		   
          }
     
 }

     return $tempTree;          // Return the entire child tree
}

 

 

hDL2rOnAOgfnfr9oa0TvIcReo1_500.jpg

Link to comment
https://forums.phpfreaks.com/topic/182584-lol/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.