Re: Getting data from table as a tree

From: Date: Sun, 08 Aug 2004 21:04:52 +0000
Subject: Re: Getting data from table as a tree
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-193142@lists.php.net to get a copy of this message
Hi Take a look at this array. It represents a simple tree. I need that because the site i'm working on uses Smarty templates an there's a way to do output the tree using 'Smarty functions' $tpl->assign("tree",array("element"=>array(array("name" => "test1", "element" => array(array("name" => "test1.1"), array("name" => "test1.2", "element" => array(array("name" => "test1.2.1"), array("name" => "test1.2.2")))))))); I took this example from smarty forum. Greetings "Brian Kell" <abodeman@yahoo.com> escreveu na mensagem news:opsccgxuibz772u5@ultramarine.unl.edu... > On Thu, 5 Aug 2004 11:24:57 +0100, Pt2002 <pt2002@mail.pt> wrote: > > > Hi > > > > I have a table like this > > id, pid, name. When a item has no parent, pid = 0. There is no limit in > > depth. > > 1, 0, Test 1 > > 2, 1, Test 1.1 > > 3, 1, Test 1.2 > > 4, 2, Test 1.1.1 > > 5, 1, Test 1.3 > > 6, 3, Test 1.2.1 > > > > I need to read this table and return an array that represents the tree. > > Maybe using a recursive function but had no success. > > > > I just need someone to point in the right direction. > > TIA > > > > Greets > > pt2002 > > Do you have an idea for representing a tree with arrays? I'm not sure how > you want to do that. If you can provide an outline of what the finished > array should look like, I can help you with some code ideas. > > Brian

« previous php.general (#193142) next »