0) { while ($row = mysqli_fetch_assoc($result)) { // $data[$x] = $row; //$data[]=$row; //$x++; $data['parent']=$row; } while ($row_child = mysqli_fetch_assoc($result1)) { $data['child'][$x] =$row_child ; $x++; } } else { $data['status'] = 200; $data['message'] = "Data not found!"; } echo json_encode($data); ?>