title: How to show category name in Product Page in Codigniter?
body: <p>I have two table in database ::: 1. tbl_category 2. tbl_product. 
  Showing all category list in home page and when user clicks on signle category then it goes to product page(from tbl_product)  by category id (included category id in tbl_product)</p>
  
  <p>Issue ::: I want to show the category Name and Image Here. So that user can see in which category they clicked on (from tbl_category ) ::: how can I get them ??? please help me </p>
  
  <h1>Controller ::::</h1>
  
  <pre><code>class Home extends CI_Controller{
  //put your code here
  public function __construct() {
      parent::__construct();
      $this-&gt;load-&gt;model('home_model');
  }
  public function index(){
      $data=array();
  
      $data['result']=$this-&gt;home_model-&gt;selectCategory($config['per_page'], $this-&gt;uri-&gt;segment(3));
  
      $data['maincontent']=$this-&gt;load-&gt;view('home_message',$data,TRUE);
      $this-&gt;load-&gt;view('home', $data);
  }
  
  public function category($category_id){
      $data=array();
  
      $data['result']=$this-&gt;home_model-&gt;selectProductByCategoryId($category_id);
  
      $data['maincontent']=$this-&gt;load-&gt;view('category_detail',$data,TRUE);
      $this-&gt;load-&gt;view('home', $data);
  }
  </code></pre>
  
  <h1>Model::::</h1>
  
  <pre><code>class Home_Model extends CI_Model{
  //put your code here
  
  
  public function selectCategory($per_page, $offset)
  {
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('tbl_category');
      $this-&gt;db-&gt;order_by("category_id", "desc"); 
  
      $query = $this-&gt;db-&gt;get('', $per_page, $offset);
      foreach ($query-&gt;result() as $row)
          $data[] = $row;
  
      return $data;
  
  } 
  
      public function selectProductByCategoryId($category_id)
  {
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('tbl_product');
      $this-&gt;db-&gt;where('category_id',$category_id);
      //$this-&gt;db-&gt;order_by("product_id", "desc"); 
      $query_result=  $this-&gt;db-&gt;get();
      $result=$query_result-&gt;result();
      return $result;
  }
  </code></pre>
  
  <h1>View::::</h1>
  
  <p>I want to show the category Name and Image Here. So that user can see in which category they clicked on ::::</p>
  
  <pre><code>&lt;?php 
          foreach ($result as $values)
          {
      ?&gt;
  
      &lt;div&gt;
          &lt;div&gt;
              &lt;a href="&lt;?php echo base_url(); ?&gt;product_category/product_detail/&lt;?php echo $values-&gt;product_id ?&gt;"&gt;&lt;img src="&lt;?php echo base_url();?&gt;&lt;?php echo $values-&gt;product_image ?&gt;" width="90%" height="220" /&gt;&lt;/a&gt;
          &lt;/div&gt;
  
          &lt;div&gt;
              &lt;b&gt;&lt;a href="&lt;?php echo base_url(); ?&gt;product_category/product_detail/&lt;?php echo $values-&gt;product_id ?&gt;"&gt;&lt;?php echo $values-&gt;product_name ?&gt;&lt;/a&gt;&lt;/b&gt; &lt;br&gt;
              &lt;b&gt;Price: &lt;?php echo $values-&gt;product_price ?&gt;&lt;/b&gt; &lt;br&gt;
              &lt;a href="&lt;?php echo base_url(); ?&gt;product_category/product_detail/&lt;?php echo $values-&gt;product_id ?&gt;" class="a-btn"&gt;Order Now&lt;/a&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;?php } ?&gt;
  </code></pre>