I've got a database table with tags. Each tag has a parent tag assigned. What I'd like to do, is to get a nested HTML list like that:
<ul> <li>Parent tag 1</li> <li>Parent tag 2</li> <ul> <li>Child tag 1</li> <li>Child tag 2</li> <ul> <li>Child tag 2.1</li> <li>Child tag 2.2</li> </ul> <li>Child tag 3</li> </ul> <li>Parent tag 3</li> </ul>
Now I'm looking for a way with PHP to get the database entries to an array (probably) to manage such a list. Has anybody any ideas how to get this done?
Just a heads up, each of those sub unordered lists need to be wrapped in a list-item tag. If not it doesn't validate. I can't help with you're current problem but this might save you some hassle later on down the road.
I've got a database table with tags. Each tag has a parent tag assigned. What I'd like to do, is to get a nested HTML list like that:
Now I'm looking for a way with PHP to get the database entries to an array (probably) to manage such a list. Has anybody any ideas how to get this done?
Thanks
http://crisp.tweakblogs.net/blog/317/fo ... query.html
@noahgelman:
You're right, I forgot that when writing that little code snippet.