简体   繁体   English

MySql PHP树视图

[英]MySql PHP tree view

I am building a web application for an affiliate program and on the users table I have this structure: 我正在为会员计划构建Web应用程序,并且在users表上具有以下结构:

图片显示结构

Based on this MySql table I want every user to be able to see his tree, so I need this query: 基于此MySql表,我希望每个用户都能看到他的树,因此需要此查询:

  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: 基本上应该是这样的:

图片显示...某物。查询可能吗?

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. 如果您的表结构确实看起来像这样,则您需要定义一个函数或更容易以您的语言(php)进行递归查找,但这实际上是一种低效的方式。 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 它比我更能解释数据库中的多层次数据存储: http ://articles.sitepoint.com/article/hierarchical-data-database

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM