Jump to content

Recommended Posts

Hi,

 

I'm wanting to make an <ul> type menu based on info in a database.

 

Each DB entry has a page URL, and page title among other info.

 

I somehow need to loop through the database and fill some arrays in a way that structures the urls for a menu.

 

The menu structure would be the same as the directory structure. For example;

 

Level One Index (index.htm)

      SubLevel One (somepage.htm)

      SubLevel Two (someotherpage.htm)

            SubLevel Three Index (/sub/index.htm)

                  SubLevel One (/sub/somepage.htm)

 

Can I sort data in PHP by its path depth, or do I need to count slashes? I feel a bit confuse at where to start  :-[

 

Cheers

 

The info is in a database. Each row has the following data. "id", "parent_id", "title", "url", "content"

 

"id" is a unique numerical key

"parent_id" is the page 'above' this one

 

There could be any number of parents and children as the site content would change over time (hence the need for a dynamic menu).

 

I'm sure it is not too tricky, I just seem to be suffering from a mental logic block  :-[

 

Does this make sense?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.