PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
id => 333
parent_id => 2
agrpcount => 0
disp_order => 334
code => PL-OD
name => Outdoors
active => 1
What I want to do is display these in a heirarchal list... I need some sort of functionality that can reorganize this one-dimensional array into a multi-dimentional array. I know this isn't difficult... in fact I've done it before, but for some reason I can't remember how, and my brain is exhausted due to lack of sleep. I bet as soon as I post this I'll try again and then have to post that I'm a moron again, but here goes...
Or something to that effect...I hope that helps get you started anyways...you could use a stack counter and avoid recursion as well as return the results as an array which is passed to a template engine, but this nails the idea home nicely and easily IMHO.
I would prefer not to query the database on every iteration... for some reason i just can't work this out in my head. It seems simple enough... but my brain just isn't doing it.
Well...you would then need to use the SQL "IN" statement I think...although I'm not sure that would actually be faster than iteratively callingtrivial SELECT's
Using this approach still requires you to build a list of children and parent relationships...sure I dunno how you did it in the past...did you use MySQL???