Hello, I have a MySQL database set up something like this: +-------------+----------------------+--------------+-------+ | lev1 | lev2 | lev3 | lev4 | +-------------+----------------------+--------------+-------+ | ELECTRONICS | TELEVISIONS | TUBE | NULL | | ELECTRONICS | TELEVISIONS | LCD | NULL | | ELECTRONICS | TELEVISIONS | PLASMA | NULL | | ELECTRONICS | PORTABLE ELECTRONICS | MP3 PLAYERS | FLASH | | ELECTRONICS | PORTABLE ELECTRONICS | CD PLAYERS | NULL | | ELECTRONICS | PORTABLE ELECTRONICS | 2 WAY RADIOS | NULL | | OUTDOORS | PATIO | BRICK | NULL | | OUTDOORS | PATIO | STONE | NULL | | OUTDOORS | PATIO | STONE | SMALL | | OUTDOORS | LAWN | LAWNMOWER | NULL | +-------------+----------------------+--------------+-------+ PHP: How can I make some hierarchical links that display something like this: +-----------------------+ | LINKS | +-----------------------+ | ELECTRONICS | | TELEVISIONS | | TUBE | | LCD | | PLASMA | | PORTABLE ELECTRONICS | | MP3 PLAYERS | | FLASH | | CD PLAYERS | | 2 WAY RADIOS | | FRS | | OUTDOORS | | PATIO | | BRICK | | STONE | | SMALL | | LAWN | | LAWNMOWER | +-----------------------+ PHP: Thanks Best
You may want to look at this: dev.mysql.com/tech-resources/articles/hierarchical-data.html. Funny how you used similar same table names and structure too, as the answer you're looking for is on that page. Honestly, if you typed the exact title of your thread on Google you would find the same link as the first result. Look at the section "Finding the Depth of the Nodes".
lol yeah, I searched Google and found that page and that's where I got the table but I couldn't understand this page well. Also, this page didn't say how to print the links out in PHP either.
Have you tried looking at the section "Finding the Depth of the Nodes"? It gives you the MySQL query to do it. Then all you need to do is loop through all the results and echo them on the page, indenting each table according to the depth value, using a PHP script, as you would normally do with any query.
I read that. I think the confusing part is the way my table is built. They are using a table where the data is organized differently than mine I think. The table in my original post is exactly the same way mine is set up in my Excel and MySQL files. I assume that my table is designed using the "Nested Set Model" ?
Well, I sort of found a solution: I used a series of "IF" and "IF ELSE" tags and a variation of them nested in eachother. I am sort of new to MySQL/PHP type sits so I'm not sure if this strategy is going to have adverse effects. Basically my end goal for this problem is to create a nice nested navigation link menu.