It's like a tree pyramid. I want to get the members sponsored by the current user. The result will be used to get its sponsored members and so on until everyone is read. How can I achieve this? I currently have this code but I can only go to level 8 since its a lot of work. I thought of recursion but I have no idea how to do it. I tried to study it but it's quite hard. can anyone please help me on this? thanks
$parent = $_GET['cued'];
$result = mysql_query("SELECT id FROM users WHERE agent = '$parent'");
$output = array();
while ($row = mysql_fetch_array($result)) {
$output[] = "sponsor = '".$row['id']."' ";
}
$sponsored = implode(' or ', $output);
// then right here, I use $sponsored to query the members sponsored by the result above..