I am new to CodeIgniter .Can some one please help me by telling how to pass `$row['main_products_cat_id'];` in model to `'id'=> 'my id here',` in controller. I tried so many ways but I failed.

Thanks!!! 

**This is my model**

```
function cart_product_records($id){

        $this->db->from('tbl_sub_products');
        $this->db->where('tbl_sub_products.sub_product_id', $id);
        $query = $this->db->get();

        foreach ($query->result_array() as $row){

            echo $row['main_products_cat_id'];
            echo $row['sub_product_id'];
            echo $row['sub_product_name'];
            echo $row['sub_product_description'];
            echo $row['sub_product_image'];
            echo $row['sub_product_price'];    
        }
        return $query->result();    
}

```

**this is my controller** 

```
function shopping_cart(){  

        $id = $this->input->get('id');    
        if($query =   $this->mod_products->cart_product_records($id)){

            $data['result'] = array(

                       'id'      => 'my id here',
                       'qty'     => my qty here,
                       'price'   => my price here,
                       'name'    => 'my product name here'

                    );
        }

 }

```