Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding an unordered list from 5 column MYSQL table in PHP (trees & recursion)
    primarykey
    data
    text
    <p>i've been trying to wrap my head around this for a while now, doing research online yielded nothing. Basically i have a 5 column table representing a tree structure. You could think of it as a directory list. Im trying to build a unordered list menu out of this.</p> <p>This is the MYSQL table:</p> <hr> <p><strong>Parent/Child/Grandchild/Grand-grandchild/grand-grand-grandchild</strong></p> <p>France/Aquitaine/Dordogne/Bergerac/Issac</p> <p>France/Aquitaine/Dordogne/Nontron/Nontron</p> <p>Cyprus/Paphos/Paphos District/Coral Bay/Coral Bay</p> <p>Denmark/South Denmark/Langeland/Rudkobing/Langeland</p> <p>Egypt/Sinai Peninsula/Red Sea/Sharm El Sheikh/Sharm El Sheikh</p> <hr> <p>The unordered list should look like this:</p> <ul> <li>France <ul> <li>Aquitaine <ul> <li>Dordogne <ul> <li>Bergerac <ul> <li>Isaac</li> </ul> </li> <li>Nontron <ul> <li>Nontron</li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> <li>Cyprus <ul> <li>Paphos <ul> <li>Paphos District <ul> <li>Coral Bay <ul> <li>Coral Bay</li> </ul> </li> </ul> </li> </ul> </li> </ul> </li> </ul> <p>etc...</p> <p>Basically producing an unordered list menu representing all five levels, grouping everything correctly.</p> <p>I have been toying with the following function to try and get what i want: <a href="http://kevin.vanzonneveld.net/techblog/article/convert_anything_to_tree_structures_in_php/" rel="nofollow">http://kevin.vanzonneveld.net/techblog/article/convert_anything_to_tree_structures_in_php/</a></p> <p>could anyone provide any further info on how to solve this? I attempted to build loops for each level but quickly found out this to be futile, and that recursive functions should be used.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload