title: not fetching data from database
body: <p>Here i have a list of same category names which comes under different parent category.when i fetch the data according to the id am getting result because id is different for all but when i fetch by category name am getting only the first results even though i have two same category names under different parent category..here is my category table</p>
  
  <pre><code>    id      category_name   parent_id
      8          men             0
      9          kids            0
      10       T-shirts          8
      11        Shirts           8
      12        Jeans            8
      13        Pants            8
      14        Shorts           8
      15        Tees             9
      16        Shirts           9
      17        Jeans            9
      18        Pants            9
  </code></pre>
  
  <p>Here am having shirts as the category name under different parent_id.when i select the id of 16-shirts am getting the value of of id 11-shirts because of the same category name.
  Here is the controller am using</p>
  
  <pre><code>public function men_clothing_image($category=null)    
  {   
  
      $category_id =$this-&gt;roxmodel-&gt;get_category_id($category);     
      $data['active_mn']='men_clothing';
  
      $data['men']=$this-&gt;roxmodel-&gt;get_category_by_parent($p_id=8);
      $data['kids']=$this-&gt;roxmodel-&gt;get_category_by_parent($p_id=9);
  
      $config['base_url'] = base_url().'men-'.$category;
      $config['per_page'] = 2;
      $config['uri_rsegment'] = 4;
      $config['use_page_numbers'] = TRUE;
      $config['total_rows'] = $this-&gt;roxmodel-&gt;count_category_images($category_id);
      $data['galllery']=$this-&gt;roxmodel-&gt;get_gallery_men_images($category_id,$config['per_page'],$this-&gt;uri-&gt;rsegment(4));
  
      $this-&gt;load-&gt;library('pagination',$config);
      $data['page_links'] = $this-&gt;pagination-&gt;create_links();
  
  
      $this-&gt;load-&gt;view('men_clothing_image',$data);
  
  }
  </code></pre>
  
  <p>Here is the model am passing</p>
  
  <pre><code> public function get_category_id($category_name)
   {
    $this-&gt;db-&gt;select('category.id');
    $this-&gt;db-&gt;where('category.category_name',$category_name);
    $result = $this-&gt;db-&gt;get('category')-&gt;row();
    if($result)
    {
     return $result-&gt;id;
    }
  }
  </code></pre>
  
  <p>i had done self join for connecting the id and category name but the output was null</p>
  
  <pre><code>public function get_category_id($category_name)
  {
  $this-&gt;db-&gt;select('c.id');
  $this-&gt;db-&gt;join('category c1','c.id=c1.category_name');
  $this-&gt;db-&gt;where('c1.category_name',$category_name);
  $result = $this-&gt;db-&gt;get('category c')-&gt;row();
    if($result)
    {
      return $result-&gt;id;
    }
  }
  </code></pre>
  
  <p>count image function as follows..</p>
  
  <pre><code>public function count_category_images($p_id)
  {
    $this-&gt;db-&gt;select('gallery.*','category.category_name');
    $this-&gt;db-&gt;join('category', 'category.id = gallery.category_id');
    $this-&gt;db-&gt;where('category.id',$p_id);
    $this-&gt;db-&gt;order_by('gallery.id','desc');
    return $this-&gt;db-&gt;count_all_results('gallery');
  }
  </code></pre>