Welcome Guest, Not a member yet? Register   Sign In
AJAX ARRAY
#3

I was able to export the data to the array variable in the model file.

My Model
Code:
public function o_get2($data) {
        $array = [];

        for ($i = 0; $i < count($data); $i++) {
            $this->db->where('varyasyon_id', $data[$i]);
            $query = $this->db->get('opsiyonlar');

            foreach($query->result() as $key => $row)
            {
                $array[$i][$key] = $row->opsiyon_baslik;
            }
        }
       
        return print_r($array);
    }

Print: Array ( [0] => Array ( [0] => S [1] => M [2] => L [3] => XL ) [1] => Array ( [0] => Kırmızı [1] => Sarı [2] => Yeşil ) )

but i can't print it on controller.

Controller???

Code:
    public function o_getir() {
        $data = $this->input->post('opts');

        $this->varyasyonlar_model->o_get2($data);
       
        foreach ($data as $key => $row) {
            $output['opsiyon_baslik'][$key] = $row->opsiyon_baslik;
        }

        echo json_encode($output);    
    }
Reply


Messages In This Thread
AJAX ARRAY - by andwise - 05-30-2020, 04:08 PM
RE: AJAX ARRAY - by InsiteFX - 05-31-2020, 08:11 AM
RE: AJAX ARRAY - by andwise - 05-31-2020, 09:47 AM
RE: AJAX ARRAY - by InsiteFX - 06-01-2020, 03:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB