tags:

views:

123

answers:

3

this is what I need to genarate

<ul id="0">
 <li >1</li>
   <ul id="1">
      <li > 11</li>
      <li > 12</li>
   </ul>
 <li > 2</li>
   <ul id="2">
      <li > 21</li>
      <li > 22</li>
   </ul>
 <li > 3</li>
<ul>

this is my "menu_item" table

id            int(11)
title         varchar(75)
link          varchar(100)
parent_id     int(11)
position      int(11)

//parent_id of 1st layer(menu categories) is 0

I got the table rowset order by parent_id and position by

SELECT 'id','title','link','parent' FROM 'menu_item'
ORDER BY 'parent_id' AND 'position';

I don't know how to generate the html code for the menu using this data. thank you

+1  A: 

Have a look at this

M42
thanks for the link. with performance wise, it's better to use a php function for this, isn't it?
neobeacon
A: 

ref 1
ref 2

org.life.java
thanks for the links
neobeacon
A: 

Hi, neobeacon,

I have written this code for you:

http://www.copypastecode.com/33259/?view=lines

Just change the connection settings at line 12 to your database settings, and it will do what you want.

If you want to change the HTML, go for lines 49 and 50 (root), line 72 (leaf items) and lines 78-82 (parent items).

Hope this helps!

J. Bruni