title: Retrieve related post with codeigniter
body: <p>I'm unable to retrieve similar post data from db with <a href="https://en.wikipedia.org/wiki/CodeIgniter_(framework)" rel="nofollow">codeigniter</a>. In my <a href="https://en.wikipedia.org/wiki/Blog" rel="nofollow">blog</a>, I have a tags field which is keeping data like 'php,mysql,mongo,java,jquery'<br>
  I just try to get similar post which is related with current posts tags. But im not getting expected result. and the problem is in my query. Its show only three post and that is 1st, last, and number 3rd one.</p>
  
  <pre><code>[CONTROLLER]
  
  public function showpost()
  {
      $data = array();            
      $this-&gt;load-&gt;view('header',$data);      
      $data['post'] = $query-&gt;result();
      $data['similar'] = $this-&gt;crudModel-&gt;getSimilarPost();
      $this-&gt;load-&gt;view('showfull',$data);
      $this-&gt;load-&gt;view('footer');
  }
  
  [MODEL]
  
  public function getSimilarPost()
  {
      $query = $this-&gt;db-&gt;get_where('blogs',array('id' =&gt; $this-&gt;uri-&gt;segment(3)));
      foreach($query-&gt;result() as $row){ $tags = $row-&gt;tags; }
      $match =  explode(',', $tags);
      for($i = 0; $i &lt; count($match); $i++)
      {
          $this-&gt;db-&gt;like('tags',$match[$i]); 
          $this-&gt;db-&gt;from('blogs');
          $sqlQuery = $this-&gt;db-&gt;get();
      }       
      return $sqlQuery-&gt;result();
  }
  
  [VIEW]
  
  foreach($similar as $row)
  {
      echo($row-&gt;btitle.'&lt;br/&gt;');
  }
  </code></pre>