I am new to codeigniter and could be better at php. I have a news item being retrieved from the database table news, it has a foreign key of partner\_id that is tied to the partners table. I want to get that value and use it to get the associated partner and display it's info. This is the latest of my attempts. I think I might be making it too hard. All relevant files are below. Thanks in advance.

In the model if the $id\_partner is being assigned in the get\_news function I don't think it is passing to the get\_partner function.

news\_model.php

```
    public function get_news($slug_news = FALSE)
{
    $this->load->helper('array');
    if ($slug_news === FALSE)
    {
        $news_query = $this->db->get('news');
        return $news_query->result_array();
    }

    $news_query = $this->db->get_where('news', array('slug' => $slug_news));
    return $news_query->row_array(); 
    global $id_partner;
    $id_partner = element('partner_id', $news_query);
}       

public function get_partner($id_partner = FALSE){

    $partners_query = $this->db->get('partners');
    $partners_query = $this->db->get_where('partners', array('id' => $id_partner));
    return $partners_query->row_array();

}

```

The $slug\_news in the view function doesn't apply to the partner part (obviously). but can I have another function?

controller, news.php

```
    public function view($slug_news)
{   
    $data['news_item'] = $this->news_model->get_news($slug_news);
    $partner_data['partner_listing'] = $this->news_model->get_partner($id_partner);
    if (empty($data['news_item']))
    {
        show_404();
    }
    $data['title'] = $data['news_item']['title'];

    $this->load->view('templates/header', $data);
    $this->load->view('news/view', $data);
    $this->load->view('news/news_partner', $partner_data);
    $this->load->view('templates/sidebar');
    $this->load->view('templates/footer');

}

```

view1, news/view.php

```
<?php
echo '<img src="/images/'.$news_item['thumb'].'" />';
echo '<h2>'.$news_item['title'].'</h2>';
echo $news_item['text'];
echo $news_item['bus_name'];
?><br>

```

and view2, news/news\_partner.php

```
<?php
echo '<h2>'.$partner_listing['bus_name'].'</h2>';
echo $partner_listing['address1'];
echo $partner_listing['address2'];
echo $partner_listing['city'];
echo $partner_listing['state'];
echo $partner_listing['phone'];
echo $partner_listing['email'];
?>

```