Codeigniter get database value in controller
<p>This is my controller</p>

<pre><code>  function index($id=NULL)
    {
         $this-&gt;load-&gt;model('article');

        $id= $this-&gt;uri-&gt;segment(3);
          $data = array('article' =&gt; $this-&gt;article-&gt;show_a_article($id),
            'sidebar' =&gt; $this-&gt;article-&gt;side_bar(9),
            'related'=&gt;  $this-&gt;article-&gt;related_keyword($article_title),
        );
          echo $article-&gt;News_News_ID;

         $this-&gt;load-&gt;view('page/baiviet',$data);

    }
</code></pre>

<p>I want to get <code>article_title</code> value from table article and put it in <code>related_workword()</code> function.</p>

<p>Update model The show a article model is to get article detail. The second model is to get all article related to the chosen article.</p>

<pre><code> function show_a_article($id)
    {
        $query=  $this-&gt;db-&gt;get_where('news_news', array('News_News_ID'=&gt;$id));
        return $query-&gt;row();
    }
    function related_keyword($rkey)
    {

        $sql="SELECT `News_News_ID`,`News_News_Headline`,`News_News_thumb1` FROM `news_news` WHERE `news_tags` like '%$rkey%' ORDER BY `News_News_ID` desc LIMIT 10";

        $query=  $this-&gt;db-&gt;query($sql);
        return $query-&gt;result();


    }
</code></pre>

<p>Update: Igot it</p>

<pre><code>echo $this-&gt;article-&gt;show_a_article($id)-&gt;News_News_Headline;
</code></pre>