![]() |
How do I make a tree view from MySQL and PHP
I have an application in the making that needs to show a treeview of files and directories.
I have it all working based on an <ul>. Each <li> is a sub file . I have a table set up with: name, parent, type, user, content, project, date, id I set up the DB to set the parent as the id of it's parent (e.g. Directory "A" has an id of "2" and parent of "0" and directory "B" has an id of "20" and a parent of "2". B would be nested inside of A because it's parent matches it's id). Here is a sample of what I want the markup to be like: HTML Code:
<ul> |
What do you currently have?
|
I actually got it thanks to a guy over at tizag.com. He wrote me a small function that worked right out of the box. Just in case anyone else needs to make a site tree of some sort using a ul (could be an ol of course):
PHP Code:
PHP Code:
|
Looks good, could be improoved, but I guess it works ^^
Though, I think you made a typo: tree_set(0) should be tree_view(0) |
| All times are GMT. The time now is 08:37 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0