function usertuandui($username){
$U = M('users');
$where['Allianceuser']=$username;
$count = $U->where($where)->count();
$page = new \Think\Page($count,20);
$showPage = $page->show();
$res = $U->where($where)->select();
if($res){
$i=1;
foreach ($res AS $row =>$k)
{
$cat_arr[$row]['xid'] = $k['id'];
$cat_arr[$row]['username'] = $k['username'];
$cat_arr[$row]['gid'] = $k['gid'];
$cat_arr[$row]['count'] = $i;
if (isset($k['username']) != NULL)
{
$cat_arr[$row]['id'] = $this->getTree($k['username'],$i);
}
}
}else{
}
$data['showPage']=$showPage;
$data['cat_arr']=$cat_arr;
return $data;
}
function getTree($username,$i){
if($i<10){
$three_arr = array();
$U = M('users');
$where['Allianceuser']=$username;
$res = $U->where($where)->select();
if($res){
foreach ($res AS $row =>$k)
{
$three_arr[$row]['xid'] = $k['id'];
$three_arr[$row]['username'] = $k['username'];
$three_arr[$row]['gid'] = $k['gid'];
$i=$i+1;
if (isset($k['username']) != NULL)
{
$three_arr[$row]['id'] = $this->getTree($k['username'],$i);
}
}
}else{
}
}else{
}
return $three_arr;
}请各位大侠帮帮忙,看看这段递归,我现在要分页啊,应该怎么弄呢? 最佳答案