PDA

Click to See Complete Forum and Search --> : Treeview structure in PHP


NehaRao
Dec 25th, 2009, 07:39 AM
Hello All

Can somebody help me in getting a treeview structure uisng PHP script. I would be fetching the details from database. I am looking for something like this

- Parent1
- Child1
- Subchild1
Content
- Parent2
+ Child2
- Child3
- Content

A -ve sign need to be shown if it is expanded , If not a +ve sign.

Can we do this is PHP Script .. Can somebody help me please.

Thank You
Neha

Justa Lol
Dec 25th, 2009, 08:27 AM
could you explain a bit more, because i believe this would be simple... where does the parent come from and where dose the child come from? and the content is that in the tree view or outside?

edit: could this help you with you want done?

http://www.berthou.com/us/2008/03/27/phptliste-an-opensource-treeview-in-php/

NehaRao
Dec 25th, 2009, 08:52 AM
Hello Justa

That is what exactly I wanted to do . Thansk for the example. But Now I need to fetch my details from the database.

Parent and childs comes from MySQL DB. When I pass the parent value , I Can fetch the child value and so on.. Hope I answered ur question

Thank You So much for immediate help

kows
Dec 25th, 2009, 10:44 AM
you pretty much just have to fetch everything that would appear in the tree at the time; so you must fetch all of the titles, and then for every title that is "open," you must fetch the subtitles, and for every subtitle, you must fetch the content. the easiest way to build it, in my opinion, is using a big array. you could probably store the menu's look in a session, or the query string.

I have absolutely no idea how you would manage this using the class listed above. the documentation for how to use it effectively doesn't even exist, but it does have a few examples; these don't seem too helpful, though. this class allows you to use text files to generate a menu, so you could cache a copy of your database in the textfile in the treeview class format so that it could use it. sounds like a pain though.

if you don't possess the knowledge to build this yourself, I'd suggest googling to find another tree-view generator instead. one that can build a tree-view from an array, or something.

Justa Lol
Dec 30th, 2009, 10:52 AM
http://www.dynamicdrive.com/dynamicindex1/navigate1.htm

i haven't got time to make anything, sorry for that, but i found a link you could try experimenting with...

kows
Dec 30th, 2009, 10:54 AM
that really doesn't help all that much; the issue is the ability to get the content and put it into the tree, not making a tree view itself. :/

Justa Lol
Dec 30th, 2009, 01:50 PM
well sorry about, i wish i could help right now but i can't, I'm too busy making a website(not for my self)... got 3 people asking me to make them websites for cash, finally got something for my knowledge, but still my 8 languages aren't useful as i'm not an interpreter.. hehehe

NehaRao
Jan 1st, 2010, 12:57 PM
I still couldnt arrive at any solution for the issue. As Kows said, its not about building the treeview. Its about populating the content from the database into treeview.

Parent1
----->Child1
--->SubChild11
-------> Child11Content
--->SubChild12
-------> Child12Content
Parent2
----->Child1
----->Child2
--->SubChild21
-------> Child21Content
--->SubChild22
-------> Child22Content

The relation and content between parents and childs is stored in mySQL DB.

NehaRao
Feb 1st, 2010, 12:24 PM
Hello

Thanks Justa

I did achieve using the example explained in

http://www.dynamicdrive.com/dynamicindex1/navigate1.htm

Thanks for it

Justa Lol
Feb 1st, 2010, 11:11 PM
oh man sorry i completely forgot this topic! :(

NehaRao
Feb 15th, 2010, 05:53 AM
Hello All

My above solution is not working in realtime. It is hitting the performance badly. I believe that the tree is loaded at the time of page loading. Its not dynamic. I would want the childs to be loaded only when the parent node is clicked . When the parent node is clicked I want to query the MySQL DB and get the childs and populate the tree.

Can anyone help me please.

Thanks
Neha

kows
Feb 15th, 2010, 11:22 AM
you didn't ever post your solution, so it's a little hard to help.

NehaRao
Feb 16th, 2010, 01:07 AM
Hello

I have implemented the same solution explained in

http://www.dynamicdrive.com/dynamicindex1/navigate1.htm

Thanks

kows
Feb 16th, 2010, 01:37 AM
that solution is simply JavaScript playing with HTML. it sounds like you're looking for an ajax-powered treeview (http://www.google.ca/search?source=ig&hl=en&rlz=&=&q=ajax+treeview+php&btnG=Google+Search&meta=lr%3D&aq=f&oq=).

penagate
Feb 16th, 2010, 07:35 PM
Your threads have been merged.