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 5972413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:39:16+00:00 2026-05-22T20:39:16+00:00

I have to create a tree view from the records of my table below

  • 0

I have to create a tree view from the records of my table below

id user_id friend_id property_id
1    123       321          1
2    123       456          1
3    456       909          1
4    909       222          1

I have the user_id i.e 123 and property_id i.e 1 I need to know how can I make a tree with friends with whom I share this property, and afterwards with users with whom my friends share this ID.

  • 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-05-22T20:39:16+00:00Added an answer on May 22, 2026 at 8:39 pm

    Ok since there are several steps I’ll start out on a high level. If you need help with any of those, ask again!

    First of all, you’ll need the “root” nodes, ie those users who don’t appear as children in the friend column.

    Then, for each of these users, start polling all their children. For this, define a function that gets all the children of a user and which calls itself recursively for the children of the child it finds.

    This is pretty abstract, because the question is what you want to do with this structure. This depends on the last part, your presentation layer. That’s what I know least about; there may be a framework which helps you visualize trees in PHP, but I don’t know. There will typically be some sort of object structure with layout properties and child objects; instantiate those properties in your recursive function from the last step.

    As a side node, it isn’t clear if the data structure you obtain is actually a tree. If you are A, have friends B and C, and C is also a friend of B, B will show up as your friend (on level 2 of the tree) and as C’s friend (on level 3). You’ll have to check what’s your desired behaviour in that spot and might have to, e.g., ignore C the second time you encounter it.

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

Sidebar

Related Questions

I have a tree (nested categories) stored as follows: CREATE TABLE `category` ( `category_id`
I want to create tree structure using web service. I have used bottom up
I have a python script that is trying to create a directory tree dynamically
I'm trying to create an expression tree dynamicly. Let asume that I have two
I have web page in ASP.NET. I have created Tree View control with jQuery.
I have a simple self referencing table as depicted here: CREATE TABLE [dbo].[Project]( [ProjectId]
Question: I have a view which I want to derive from a recursive query.
I have a requirement to create a multi level treeview in ASP.Net (with VB)
I am using ExtJS 4. I have created a tree panel as var treeStore
For a new project I have created a local folder tree with empty Visual

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.