I write this recursive function but its not working. Not able to find the mistake. Its not returning anything. But If I write an "echo" on else statement its printing perfectly.
function find_parent($referralid,$leg)
{
$query="SELECT memberid FROM memberdetails where parentid='".$referralid."' and leg='".$leg."'";
$result=mysql_query($query);
if (mysql_num_rows($result) == 0)
return $referralid;
else
{
while($row = mysql_fetch_array($result))
{
find_parent($row[0],$leg);
}
}
}