I have a recursive function that returns a value.
public function getparent ($user)
{
$referrer=''; $pos=0;$this->setFieldNames();
$result=mysql_query("select * FROM ". $this->dbtablename ." WHERE ".$this->id_field . " = '$user'", $this->dbConnectionID);
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$referrer=$row['referrer'];
$export=array();
foreach($this->tablefields as $val){
$export[$val] = $row[$val];
}
}
if($referrer != "0" && $referrer != "")
{
$result2=mysql_query("select * from " . $this->dbtablename . " where " . $this->id_field . " ='$referrer'", $this->dbConnectionID);
while($row2=mysql_fetch_array($result2, MYSQL_ASSOC))
{
$export=array();
foreach($this->tablefields as $val){
$export[$val] = $row2[$val];
}
}
}
$result2=mysql_query("select * from " . $this->dbtablename . " where " . $this->parent_id_field . " ='$referrer' order by id asc", $this->dbConnectionID);
while($row2=mysql_fetch_array($result2, MYSQL_ASSOC))
{
$usernames[]=$row2['username'];
}
$pos=array_search($user, $usernames);
if( $referrer == '0' || $pos >=1 )
{echo 'xxxxxxx';
return $export;
}
else
{
$this->getparent($referrer);
}
}
It seems that when the $referrer is zero it doesnt return any value, yet it echoes 'xxxxxxx'. What can the problem be!?