我的代码:
function query_list($uid){
$sql = "select username,mobile,uid from " .$this->table_name. " where p_uid=".$uid;
$query = $this->db->query($sql);
$info = $query->result_array();
if($query){
foreach($info as $k=>$v){
$sql = "select username,mobile,uid from " .$this->table_name. " where p_uid=".$info[$k]['uid'];
$query = $this->db->query($sql);
$info_c = $query->result_array();
$info[$k]['child'] = $info_c;
$this->query_list($info[$k]['uid']);
}
}
return $info;
}
查询结果:
{
"error_code": "0000",
"msg": "success",
"data": [
{
"username": "澹台削影",
"mobile": "15600604363",
"uid": "100001301",
"child": [
{
"username": "李四1",
"mobile": "15600604363",
"uid": "100001302"
}
]
}
]
}
第三往后的等级就查不出来了。望高手指点迷津!