$query = mysqli_query($con, "SELECT * from users ");
while($row = mysqli_fetch_object($query))
{
$sub_data['id'] = $row->user_id;
$sub_data['name'] = $row->username;
$sub_data['parent_id'] = $row->parent_id;
$data[] = $sub_data;
}
foreach($data as $key => &$value)
{
$output[$value['id']] = &$value;
}
foreach($data as $key => &$value)
{
if($value['parent_id'] && isset($output[$value['parent_id']]))
{
$output[$value['parent_id']]['node'][] = &$value;
}
}
我想使用这种查询“ SELECT * from parent_id ='20'的用户”。 但是我没有在这个parent_id上获得所有树成员