Re: Getting data from table as a tree
| From: | pt2002 | Date: | Thu, 05 Aug 2004 17:16:01 +0000 |
| Subject: | Re: Getting data from table as a tree | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192906@lists.php.net to get a copy of this message | ||
Thank you for your suggestion.
I've had already browse pear classes but didn't want to use them.
I've found some tips and now I can show the tree but I also need to have all
the data in an array and that's the problem now.
Greetings
pt2002
"Pt2002" <pt2002@mail.pt> escreveu na mensagem
news:20040805102558.10811.qmail@pb1.pair.com...
> 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