开发者

MySql PHP tree view

I am building a web application for an affiliate program and on the users table I have this structure:

MySql PHP tree view

Based on this MySql table I want every user to be able to see his tree, so I need this query:

  1. The user to see who recruited him and who was recruited by him and I don't开发者_开发知识库 want the query to show other users that are recruited by the same recruited that recruited this user. Basicly it should look this way:

MySql PHP tree view


if your table structure really looks like this you ned to define a function or easier do it in a recursive lookup in your language (php), but its a really inefficient way. read this article it deals with this recursive and other teqniques.

it explains storing of hirachical data in databases better than i could: http://articles.sitepoint.com/article/hierarchical-data-database

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜