function myFun($id,$ppid) { $resource=mysql_query("select * from table where id=$id"); $result=mysql_fetch_array($resource); if ($result['ppid']==$ppid) return $result; else myFun(result['ppid'],$ppid); }//调用 myFun,从a查到m $myResult=myFun('a','m');估计应该差不多了吧
晕,我忘记给sql语句加''了,应该是 "select * from table where id='".$id."'"
{
$resource=mysql_query("select * from table where id=$id");
$result=mysql_fetch_array($resource);
if ($result['ppid']==$ppid) return $result;
else myFun(result['ppid'],$ppid);
}//调用 myFun,从a查到m
$myResult=myFun('a','m');估计应该差不多了吧
"select * from table where id='".$id."'"
还有忘记$,应该是$result['ppid']