Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6635617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:04:37+00:00 2026-05-25T23:04:37+00:00

I work on this issue since yesterday. More specifically – I have some values

  • 0

I work on this issue since yesterday. More specifically – I have some values ​​in the database, which look as follows:

____________________________________
| id | parentId |   name   |  url  |
------------------------------------
| 1  |     0    | Nieuws   | url_1 |
------------------------------------
| 2  |     0    | Reviews  | url_2 |
------------------------------------
| 3  |     0    | Meuk     | url_3 |
------------------------------------
| 4  |     1    | Games    | url_4 |
------------------------------------
| 5  |     1    | Internet | url_5 |
------------------------------------
| 6  |     5    | Browsers | url_6 |
------------------------------------

I would like to see generated tree on the basis of these values. Target shape should look like this:

<ul>
    <li><a href="url_1">Nieuws</a>
        <ul>
            <li><a href="url_1/url_4">Games</a></li>
            <li><a href="url_1/url_5">Internet</a>
                <ul>
                    <li><a href="url_1/url_5/url_6">Browsers</a></li>
                </ul>
            </li>
        </ul>
    </li>
    <li><a href="url_2">Reviews</a></li>
    <li><a href="url_3">Meuk</a></li>
</ul>

It’s important for me to have all the slashes inside the tree (full path with all the parents & children).

I would like to add, that I found the code on this page: http://crisp.tweakblogs.net/blog/317/formatting-a-multi-level-menu-using-only-one-query.html but I can not redo it in such a manner as described above. I’ll be very grateful for any help, because the application deadline is approaching very fast 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:04:38+00:00Added an answer on May 25, 2026 at 11:04 pm

    Only one modification. I think this way is much simpler. Instead of using an array to store the URL, I pass a string as an argument (containing the base url).

    // menu builder function, parentId 0 is the root 
    function buildMenu($parentId, $menuData, $urlRoot) 
    { 
        $html = ''; 
    
        if (isset($menuData['parents'][$parentId])) 
        {
        $html = '<ul>'; 
        foreach ($menuData['parents'][$parentId] as $itemId) 
        { 
            $url   = $urlRoot . $itemId['url'] . '/';
            $html .= '<li><a href="$url">' . $menuData['items'][$itemId]['name'] . '</a>'; 
    
            // find childitems recursively 
            $html .= buildMenu($itemId, $menuData, $url); 
    
            $html .= '</li>'; 
        } 
        $html .= '</ul>'; 
        } 
    
        return $html; 
    } 
    
    // output the menu 
    echo buildMenu(0, $menuData, '');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue getting a LINQ query to work. I have this XML:
i'm working since hours on this issue without any success, hope to get some
I'm a beginner programmer, and am wondering how to work around this issue. The
I'm having an issue getting this CSS for a sprite sheet to work on
(This is no homework and no work issue. It's just my personal interest/occupation and
This is a really basic issue, but I'm new to perl and cannot work
Im having issues getting this to work, maybe its not even possible? I have
I'm trying to work this out. In my project, i have a file called
Ok I'm at my work this friday setting up a table that will have
Work on this small test application to learn threading/locking. I have the following code,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.