PHP How to cycle query member recommendations, as well as to the member points, direct relationship 5 points, indirect relationship 1 points, ask you to help solve.

Source: Internet
Author: User
Table field is like this, query direct relationship is OK
$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;}

But how to deal with the indirect relationship, the top is fid=0. For example, I am 2203 that ID, the following direct relationship has 2204, 2207, 2206 and so on, and then the indirect relationship is 2204 below the 2210, 2208 and so on, how to find out a member of the following all direct recommendations and indirect recommendations, and accumulate it. Brother Small white, please God help.


Reply to discussion (solution)

No one ... Ask for help ...

One layer at a cover.
Study name recursion

No one ... Ask for help ...


Alas, for a day, a little clue is not, ask the big God answer
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.