Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8044101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:07:13+00:00 2026-06-05T05:07:13+00:00

Am working on a project that needs to create children and grandchildren using a

  • 0

Am working on a project that needs to create children and grandchildren using a root ID

It works in this way
user_1 registers himself, he(user_1) also registers 2, 3, 4, 5, 6 and have total(maximum) of 5 children
user_2 registers 7, 8, 9, 10, 11
user_3 registers 12, 13, 14, 15, 16
and so on

ON user_1’s profile a tree table lists out his children and from his children,
the grandchildren he has from each of the registered children is also displayed.

                                   1
 ----------------------------------------------------------------------
    |                  |                  |               |                |
     2                3                  4               5                6
---------------     ---------------   ---------------  ------------   -------------- 
|   |   |  |  |     |   |   |  |  |   |  |   |  |  |   |  |  |  |  |  |  |  |   |   |
7   8   9  10 11    12  13 14 15  16  17 18  19 20 21  22 23 24 25 26 27 28 29 30  31                        

The User_ID’s would not necessarily be in order but just an example
Then also, USER 1 would see the total of children and grandchildren he has
The maximum of Children = 5, grandchildren = 20 == (25)

I have created a table like this

 id | name  | password | totalfamily | grandparent | parent_id
 ---------------------------------------------------------------

I would want the table to be hold info like this the one below

id | name  | password | totalfamily | grandparent | parent_id
1     jon     ******                  NULL          NULL
2     mel     ******                  NULL          1
3     al      ******                  NULL          1
4     me      ******                  1             3

if there is need for new table structure to make it work, that will be ok too.

I have done the procedures for registration(including checking for the parent_id and grandparent_id) and the logging in

But am in a fix concerning how to QUERY the database to help me list out the names like a tree structure to show the children and the grandchildren

I know it needs complex querying statements to execute

I am in urgent need of solving this(hope it doesn’t break the rules) as I have spent days reading Hierarchical data structuring tutorials for my Mysql+PHP yet none seems easy to be heading my direction.

Help anyone???
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:07:14+00:00Added an answer on June 5, 2026 at 5:07 am

    I have just created table with id,name parent_id

    +----+--------+-----------+
    | id | name   | parent_id |
    +----+--------+-----------+
    |  1 | one    |      NULL |
    |  2 | two    |         1 |
    |  3 | three  |         1 |
    |  4 | four   |         2 |
    |  5 | five   |         2 |
    |  6 | six    |         2 |
    |  7 | seven  |         2 |
    |  8 | eight  |         3 |
    |  9 | nine   |         3 |
    | 10 | ten    |         3 |
    | 11 | eleven |         3 |
    +----+--------+-----------+
    

    and when user 1 want to get all the child. Query will like this

    select * from users where parent_id in(select id from users where parent_id = 1) or parent_id = 1;
    

    I think it may help you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project where I need to create a link that when
I am working on some project that needs that when ever a friend of
I'm working on a project that needs to have a list of weekdays. I
I am working on a project that needs rasterizing of drawings into image files.
I'm working on a project that needs a simple, lightweight event server (i.e. a
I'm working on a project that needs to have flexible authorization. What I mean
I'm working on a project that needs to check the time difference from a
I am working on a php project that needs to store information about various
I am currently working on a SharePoint project that needs to use the Lists
I currently started working on a maven web-app project that needs to be launched

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.