Actually I am stucked here, I want to get the data of current User and the current User's referrer's data and referrer's referrer data.
Like A is the first User, the B is second, the C is third, the D is fourth. If the user A is logged in then the query should get the user A's data first and under that there should be the the data of user B because user B is referred by user A and under B there should be the data of user C because the user C is referred by User B and so on for User D.
These all data should be show under the User A's login. I am currently getting only 1 referrer data by this query:
$querySelect = "Select * from tbl_users where UserID = '$UID'";
$resultSelect = mysqli_query($conn,$querySelect);
$numSelect = mysqli_num_rows($resultSelect);
$FetchedSelect = mysqli_fetch_assoc($resultSelect);
if($numSelect > 0)
{
$refID = $FetchedSelect['refID'];
//some code to show the the table data...
}
$querySelect1 = "Select * from tbl_users where UserID = '$refID'";
$resultSelect1 = mysqli_query($conn,$querySelect1);
$numSelect1 = mysqli_num_rows($resultSelect1);
$FetchedSelect1 = mysqli_fetch_assoc($resultSelect1);
if($numSelect1 > 0)
{
//do some codes to show the table data
}
In this way I am just getting two user's data of Current User and Current User's referrer. But I want to get all users data of upper line as I mentioned on the top of this post. How can I achieve that?