Treehouse: Grow your CSS skills. Land your dream job.

Tags in a nested array/HTML list

  • # July 8, 2010 at 11:23 am

    Hi there

    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:

    Code:
    • Parent tag 1
    • Parent tag 2
    • Child tag 1
    • Child tag 2
    • Child tag 2.1
    • Child tag 2.2
  • Child tag 3
  • Parent tag 3

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

# July 8, 2010 at 2:18 pm

not exacly the same but the technique in this blogpost can be used for your problem aswell:

http://crisp.tweakblogs.net/blog/317/fo … query.html

# July 12, 2010 at 7:39 pm

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.

# July 13, 2010 at 12:54 am

Thanks to Argeaux for the link. I’ve bookmarked it, it’s very useful for recursions.

@noahgelman:
You’re right, I forgot that when writing that little code snippet.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.