Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass data from function to other function in ci3

I have 2 function like this

class Infograph extends CI_Controller
{
    public function index()
    {
    $wilayah = $this->input->post('wilayah', TRUE);
        $kodeSubWilayah = $this->input->post('subWilayah', TRUE);

        if ($kodeSubWilayah) {
            $kodeSubWilayah = $this->encryption->decrypt($kodeSubWilayah);
            if ($kodeSubWilayah === false) {
                redirect('test/404');
            }
        }

        if ($wilayah) {

            $data['wilayah'] = strtolower($wilayah);
        }

        if ($kodeSubWilayah) {
            $data['subWilayah'] = $db2->query("SELECT * FROM provinsi WHERE id = ?", [$kodeSubWilayah])->result_array();
        } 
    }

    public function export()
    {
        // i want to send data $data['wilayah'] and $data['subWilayah']
    }

}

How can i pass the data into the export fucntion? i want to get the $data[‘wilayah’] and $data[‘subWilayah’]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

use function parameters public function export($datawilayah,$datasubWilayah)

call the export function inside index function like $this->export($data['wilayah'],$data['subwilayah'])

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading