Thank You, But what I need is something else
1) Now on 16/07/2015 ID 1 (A) referred ID 2 (B), ID 3 © and ID 4 (D)
2) As he has referred 3 people he is eligible for a bonus 5% on any sales happening under him through him or through B, C AND D.
3) Now on 20/07/2015 ID 2 (B) also referred three people to business ID 5 (E), ID 6 (F) and ID 7 (G)
4) NOW ON WARDS what ever business happening under ID 2 (B) should fetch 5% only to ID 2 (B) and not to ID 1 (A).
5) ID 1 (A) will get 5% bonus from business happening under ID 3 © and ID 4 (D) till they also qualify by referring three persons each.
I am having a table called register in MYSQL. In that there is a column called user_rank. if 3 referrals are there for an ID the user_rank column will have value "YES"
When a new member joins the new Id has to see whether the up line or the person who sponsored him is having value YES in the user_rank column in register table. If not then it has to check whether the sponsor of his sponsor is having that , if not it has to check the sponsor's, sponsor's sponsor. This checking should go on till it finds an up line having a value YES inside the user_rank column . I am writing this coding in a php file. I need a php code for the same. Is there any loop which can go on checking rows up till the value is found. Please help me in this.