• 0

[PHP] Dynamic Multi-Level Menu


Question

Hoping someone can help me as i've spent hours on this now... and figured someone here could help :)

So i'm running the following SQL command:

SELECT pscl.name as text, pscl.id_category as link, psc.id_parent as parent FROM ps_category_lang as pscl INNER JOIN ps_category as psc on pscl.id_category = psc.id_category WHERE psc.active = 1 AND pscl.id_category != 1'

I then create a menu array using:

while($row=mysql_fetch_assoc($result)) {
  $menu[] = $row;
  $count++;
}

I need to take the text, the link (id) and the parent id to create a navigation menu.

So essentially i would like:

<b>Title</b>
<ul>
  <li><a>Sub link 1</a></li>
  <li><a>Sub link 2</a></li>
</ul>
<b> title 2</b>
<ul>
  <li><a>Sub link 3</a></li>
</ul>

etc

Does anybody have any idea of how this could be done easily? i figure it required building the menu, checking for child elements and adding it. Or re-organising the array at first to make the correct order for display...

Thanks so much in advance!!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.