In php, how does one cyclically query the number of recommended members and give them points? the direct link is 5 points, and the indirect link is 1 point. Please help solve this problem.

Source: Internet
Author: User
In php, how does one cyclically query the number of recommended members and give them points? the direct link is 5 points, and the indirect link is 1 point. Please help solve this problem. The table field is like this, and the direct query relationship is fine.
$ 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 indirect relationships? the top level is fid = 0. For example, if I am the id of 2203, there are 2204, 2207, 2206, and so on, and then the indirect relationship is 2204 and 2210 under 2208, etc, how can I find all direct and indirect recommendations under a member and accumulate them. Hello, Tom. please help me.


Reply to discussion (solution)

Nobody... Please help...

Check the data layer by layer.
Learning name: recursion

Nobody... Please help...


Alas, after a day, I have no clue at all. please help me.

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.