~~~php //本级别的id $this->getSup($member['id']); ~~~ ~~~php public function getSup($id,$n = 0) { global $_W; global $_GPC; $res = pdo_get('ewei_shop_member', array('id' => $id)); //有上级 if ($res['agentid']!=0) { if($n){ $ids .= "," . $res['agentid']; }else{ $ids =$res['agentid']; } $n++; $ids .= $this->getSup($res['agentid'],$n); } return $ids; } ~~~