doupo5178 2018-09-05 10:32
浏览 46

如何在一列中智能地迭代json数据

i have show json data but not properly show i want the output please suggest me.

{
    "Childs": "12,16",
    "childs_id": "12",
    "firstname": "Ratanveer",
    "lastname": "Singh",
    "admission_no": "CS-101",
    "roll_no": "1121510025",
    "admission_date": "2018-07-11",
    "rte": "No",
}

i have make api this data show are only childs "12" but i want to show both data of childs "16" and "12" in json format

MOdel: This is my model

public function getProfile() 
{
        /* ---------- Join Query ---------------- */
        $childs  = $this->input->get_request_header('Childs-ID', TRUE);
        //this is my query
        $this->db->select('users.childs AS Childs,users_authentication.childs_id,students.firstname,students.lastname,students.admission_no,students.roll_no,students.admission_date,students.firstname,students.lastname,students.rte,students.mobileno,students.email,students.state,students.city,students.pincode,students.religion,students.cast,students.dob,students.gender,students.current_address,students.permanent_address,students.bank_account_no,students.bank_name,students.ifsc_code,students.father_name,students.father_phone,students.father_occupation,students.mother_name,students.mother_phone,students.mother_occupation,students.guardian_name,students.guardian_relation,students.guardian_phone,students.guardian_occupation,students.guardian_address,students.guardian_email');
        $this->db->from('users');
        $this->db->join('students', 'students.id = users.childs','INNER');
        $this->db->join('users_authentication', 'users_authentication.childs_id = students.id','INNER');        
        $this->db->where('user_id',$childs);
        $this->db->GROUP_BY('user_id');
        $query = $this->db->get()->result();
        return ($query);    
}

Controller: This is my Controller

public function childProfileDetails()
{
    $method = $_SERVER['REQUEST_METHOD'];
    if($method != 'GET')
    {
        json_output(400,array('status' => 400,'message' => 'Bad request.'));
    }
    else
    {
        $this->load->model('MyModel');
        $response = $this->MyModel->auth();
        if($response['status'] == 200)
        {   
            $resp = $this->MyModel->getProfile();
            json_output($response['status'],$resp);
        }
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改
    • ¥20 wireshark抓不到vlan
    • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
    • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持