Home > Backend Development > PHP Tutorial > php中怎样循环查询会员推荐个数,以及给会员积分,直接关系5分,间接关系1分,求各位大大帮忙解决。

php中怎样循环查询会员推荐个数,以及给会员积分,直接关系5分,间接关系1分,求各位大大帮忙解决。

WBOY
Release: 2016-06-23 13:29:30
Original
1097 people have browsed it


表字段是这样的,查询直接关系还好办

$sql="SELECT COUNT(*) AS count FROM user_relation WHERE formId='".$id."'";	$query=mysql_query($sql);	if($rs=mysql_fetch_array($query)){	    $count=$rs[0];	}else{	    $count=0;	}
Copy after login

但是间接关系怎么来处理呢,最顶级的就是fid=0的。比如我是2203那个id,下面直系关系的有2204、2207、2206等等,然后间接关系就是2204下面的2210、2208等等,请问怎么查询出某个会员下面所有的直接推荐和间接推荐,并且累加呢。小弟小白,请大神帮帮忙。


回复讨论(解决方案)

没人吗...求帮忙...

一层一层套着查就是了
学名叫 递归

没人吗...求帮忙...


唉,搞了一天,一点头绪都没有,求大神解答
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template