Jump to content

Tree structure solution in php and mysql


tejasjoshi

Recommended Posts

I have one table which has three fields. MId Name and ParentId.

 

Suppose i have following table.

 

MId      Name      ParentId

 

1        a            0

2        a1          1

3        a2          1

4        a3          1

5        a4          1

6        a11          2

7        a12          2

8        a13          2

9        a111        6

10        a112        6

11        a113        6

12        a1111        9

13        a1112        9

14        a1113        9

15        a1114        9

 

Above table shows the MId(memberid), membername and parent of member.

 

I want to get all the child of particular member.

 

Suppose i have Mid=2 then we can get all the childs and subchilds of MId 2.

 

We can get result in following format.

 

Parent        Child

a1              a11

a1              a12

a1              a13

a11            a111

a11            a112

a11            a113

a111            a1111

a111            a1112

a111            a1113

a111            a1114

 

 

I need solution of this question as soon as possible.

please help me.

 

Thanks in advance

Link to comment
Share on other sites

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.