开发者

Need to build N-level Tree Structure Menu for Custom LMS using php/mysql

Can any body please help me with indexing of parent-child Hierarchy Menu like

Basically, iam creating a personal lms.

Main (K-12,NCERT)
->Class (Class 3,Class 4,Class 5)
->Subject (Physics,Chemistry)
->Units (Unit 1,Unit 2)
->Chapter (Chap 1, Chap 2)
->Topic (Topic 1, Topic 2)
->Sub Topic (Sub Top 1, Sub Top 2)
->Sub Sub Topic (Sub Sub Top 1, Sub Sub Top 2)

every topic have its own title and contents(text,swf,quality check status)


- NCERT   
       Class 5   
       Class 6
       Class 6_Physics
         Class 6_Physics_Unit 4
           Class 6_Physics_Unit 4_Chapter 1
           Class 6_Physics_Unit 4_Chapter 2
             Class 6_Physics_Unit 4_Chapter 2_Topic 1
             Class 6_Physics_Unit 4_Chapter 2_Topic 2
             Class 6_Physics_Unit 4_Chapter 2_Topic 3
                --Class 6_Physics_Unit 4_Chapter 2_Topic 3_Sub Topic 1
             Class 6_Physics_Unit 4_Chapter 2开发者_开发问答_Topic 4
           Chapter 3
         Unit 5
       Class 6_Chemistry
       Class 6_Biology   Class 7   Class 8
       Class 8_Physics
         Class 8_Physics_Unit 1
       Class 8_ Chemistry
       Class 8_Biology
         Class 8_Biology_Unit 4
         Class 8_Biology_Unit 5

1
2
3
3.1
3.1.1
3.1.1.1
3.1.1.1.1
3.2
3.3
4
5
...
...
n

Thanks Seyed


If you're asking about the best DB schema, then create a topic table like so:

|COLUMN NAME    |DATA TYPE
|---------------|-----------------------------------------------------
|id             | unsigned int, auto-increment, Primary Key, not null
|parent_id      | unsigned int, not null
|title          | varchar(size-as-appropriate)
| ...           |  ... and so on

So each record has a unique id. If parent_id is 0 then it is a top-level item, otherwise it is a child of whatever record has an id equal to the given parent_id.

The queries to find children/parents should be quite easy to figure out.

If you want to use MySQL for serious stuff, then I suggest you do some research into relational database design and normalization.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜