Multi Level Nested Referral system in php and mysql

Image result for Multi,Level,Nested,Referral,system,in,php,and,mysql

I have a members system ready with basic details in mysql like

id
name
email
contact

I want to now create a multilevel system in this. Like if A referred B and B referred C and C referred D, then A’s referred members should show both B and C, whereas B’s referred members should show C & D. But C’s referred members should show only D.

I am using Mysql and unable to show both B and C in A. Please help me with this.

source:-.sitepoint