...

View Full Version : building dynamic menu problem ??



PHPycho
11-29-2007, 05:28 AM
Hello forums!!
I am getting bit problem in displaying dynamic css menus which uses <li><ul> tags.
I had the table with structure as:
tbl_cat

|id|title|parent_id|
|1|Item 1| 0 |
|2|Item 2| 0 |
|3|Item 3| 0 |
|4|Item 4| 0 |
|5|Item Item 2.1| 2 |
|6|Item Item 2.2| 2 |
|7|Item Item 3.1| 3 |
|8|Item Item 3.2| 3 |
|9|Item Item 3.3| 3 |

I have to show these values as following in order to display the proper multilevel menu.

<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a>
<ul>
<li><a href="#">Item 2.1</a></li>
<li><a href="#">Item 2.2</a></li>
</ul>
</li>
<li><a href="#">Item 3</a>
<ul>
<li><a href="#">Item 3.1</a></li>
<li><a href="#">Item 3.2</a>
<ul>
<li><a href="#">Item 3.2.1</a></li>
<li><a href="#">Item 3.2.2</a></li>
<li><a href="#">Item 3.2.3</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Item 4</a></li>

Has anybody some idea in generating proper <li><ul> tags for the fields so that it becomes as above ..
Note it can be n level deep.
Thanks in advance for any tips and suggestions.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum