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.