'Message: Undefined index: when getting column name (two table with the same column) CodeIgniter

I want to get the data from two tables with the same column name. I already put some aliases in the column name. But it doesn't work.

Controller

public function price_master_list(){

    $result['mediacat'] = $this->em->getmedia_with_category();
    $this->load->view('price_master_list',$result);
}

Model

function getmedia_with_category(){
    $query2 = $this->db->select('*','m.name as `catname`', false)->from('media as m')->join('media_category as c', 'c.media_id = m.id')->where('m.delete_flag','1')->get();
    $response = $query2->result_array();
    return $response;
}

View

<?php foreach($mediacat as $medcat){ ?>
<tr>
    <td><?php echo $medcat['catname']; ?></td>
</tr>
<?php } ?>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source