How To Form Tree Structure by using php Script .

Discussion in 'PHP' started by Sapare Narasimha, Nov 29, 2015.

  1. #1
    For Example i signup in one site they give one referral code to me , with my referral code only two can join , more then two members cant join its condition . Then first signup person should come on left and second person on right , like this it should go chain process , please help me from this .
     

    Attached Files:

    Sapare Narasimha, Nov 29, 2015 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Hi Sapare,

    Do you want the database structure also? In php it can be a nested object and/or can be an associated Array.

    Example
    
    $Tree = Array(
        "root" => Array( // << Has Nodes
            "person1" => Array( // << Has Nodes
                "person1" => Array() //no further nodes
                   ,
                "person2" => Array(
                    "person1" => Array() //no further nodes
                    ,
                    "person2" => Array() //no further nodes
                   ),
                    ),
            "person2" => Array() //no further nodes
        ),
    );
    
    Code (markup):
    Best way of storing this kid of structure would be NoSQL (i.e. MogoDB, CouchDB, ArangoDB etc), but such structure may be stored and retrieved from/to SQL database as well. A single table can do the job - retrieval using SELF-JOIN.

    I hope it helps.

    stay well.
     
    Vooler, Nov 30, 2015 IP
  3. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #3
    There are many ways to do this actually.

    1. SVG
    2. HTML 5 canvas
    3. Flash
    4. GD generate image
    5. Normal tabular format of N depth

    But, I need to know how the data is formated, I mean the input data, in what format the input data is?

    stay well ....
     
    Vooler, Nov 30, 2015 IP