Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder darksecu's Avatar
    Join Date
    Dec 2011
    Location
    India
    Posts
    96
    Thanks
    11
    Thanked 1 Time in 1 Post

    learning to make tree

    i am looking to make a tree structure of users.

    this is how my members table looks
    id - username - few more columns - sponsor

    i need to create a tree structure using 2 fields, id and sponsor ..

    sponsor fields contains id of parent user.

    Thanks,
    Rahul
    When You Begin To Practice,That's The Time You Begin To Learn New Things.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Okay, and your question is what?
    Trees are written with either recursion or loop trickery, or you can write a tree or directional graph datastructure and iterate it using breadth first. In either case dumping the data from a query into an array or datastructure is a lot easier to work with than an active resultset.

  • #3
    New Coder darksecu's Avatar
    Join Date
    Dec 2011
    Location
    India
    Posts
    96
    Thanks
    11
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Fou-Lu View Post
    Okay, and your question is what?
    Trees are written with either recursion or loop trickery, or you can write a tree or directional graph datastructure and iterate it using breadth first. In either case dumping the data from a query into an array or datastructure is a lot easier to work with than an active resultset.
    sample code that can do my work
    When You Begin To Practice,That's The Time You Begin To Learn New Things.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by darksecu View Post
    sample code that can do my work
    Then google up for a PHP tree. I'm sure there are a lot of examples for using tree datastructures, graphs and recursive or iterative building of a tree.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •