PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 5, 2022

[FIXED] How to Explode data from database in controller of CodeIgniter?

 March 05, 2022     codeigniter, php     No comments   

Issue

I have a question, I want to change string data from database using explode, because the data is imploded before when I post it to the database. Here's my controller

    public function add_detail()
    {
        $symptoms_id = implode(',', $this->input->post('symptoms_id'));
        $CF_user = implode(',', $this->input->post('CF_user'));
        $data = array(
            'symptoms_id' => $symptoms_id,
            'CF_user' => $CF_user

        );
        $this->db->insert('consultation_detail', $data);
        redirect('User/consultation_result', $data);
    }

That function is to implode and it works, but I want to make a function in controller too for explode the data.

I just try like this

    public function consultation_result()
    {
        $data['consultation_detail'] = $this->db->get('consultation_detail')->row();
        $CF_user = explode(',', $CF_user);
    }

But it said undefined $CF_user , I'm sorry because I'm newbie :(


Solution

try this

public function consultation_result($data)
{
    return explode(',', $data);
}

and use like this

$data = array(
        'symptoms_id' => consultation_result($this->input->post('symptoms_id')),
        'CF_user' => consultation_result($this->input->post('CF_user'))
    );


Answered By - AGK
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing