Forum Moderators: coopster

Message Too Old, No Replies

Building a tree structure

         

hswaseer

10:44 am on Jan 24, 2005 (gmt 0)

10+ Year Member



Hi,

I want to built a tree structure so that it shows that on which category level i am currently. like

HOME > COMPUTERS > HARDWARE > CABLES

My table look like this

catid parentid name
1 0
2 1 Computers
3 1 Scicence
4 2 Hardware
5 2 Internet

and so on

How should i go about this....any good tutorial anybody knows where i find the solution to my problem.

HS

lZakl

2:26 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



Wouldn't you just use a foreach loop?

$current_catid = "whatever your current catid is";

foreach ($catid as $value)
{
if ($current_catid <= $catid)
{
echo "$value >";
}
}

Maybe I'm seing it as more simple than it actually is? If this isn't what you are looking for, I'm sorry :0)

--Zak

[edited by: lZakl at 2:33 pm (utc) on Jan. 24, 2005]

johnnie

2:28 pm on Jan 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Breadcrumbing... Use your directory structure for that!