title: get record by id in codeigniter
body: <p>I have a problem passing values ​​in a column according to the id of the product </p>
  
  <p>The join tables is running but returns all column values. 
  I think the solution is simple but I am not able to get there. 
  Please some help to solve this issue?</p>
  
  <p>Here is the tables </p>
  
  <h1>TABLE: tbl_lining</h1>
  
  <p>id,
  article,
  description,
  observations</p>
  
  <h1>TABLE:products</h1>
  
  <p><img src="https://i.stack.imgur.com/04HTf.png" alt="[Table Products - picture](http://www.webmark.com.pt/pics/products.png)"></p>
  
  <p>Function used in model</p>
  
  <h1>MODEL</h1>
  
  <pre><code> public function getliningsale($id)
  {
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('products');
      $this-&gt;db-&gt;join('tbl_lining', 'products.lining=tbl_lining.id', 'left');
      $this-&gt;db-&gt;where('products.id', $id);  // Also mention table name here
      $query = $this-&gt;db-&gt;get();    
      if($query-&gt;num_rows() &gt; 0)
          return $data-&gt;result();
  }
  </code></pre>
  
  <h1>CONTROLLER</h1>
  
  <pre><code>function liningsale()
  {   
  
  $data['lining'] = $this-&gt;sales_model-&gt;getliningsale($id);
  $this-&gt;load-&gt;view('add', $data);
  }
  </code></pre>
  
  <p>Trying to display one record according product id</p>
  
  <h1>VIEW</h1>
  
  <pre><code>echo '&lt;td&gt;&lt;input class="span1 tran2" name="lining\'+ count +\'" type="text"';
  echo 'value="';
   foreach ($liningsale as $valor) {
   echo $valor-&gt;article;
   echo '-';
   echo $valor-&gt;description; 
   echo '"&gt;';
   }
  
  echo '&lt;/td&gt;';
  </code></pre>
  
  <p>Instead of that, is displaying all records</p>
  
  <p><img src="https://i.stack.imgur.com/1rW16.png" alt="[Table Result - picture](http://www.webmark.com.pt/pics/result.png)"></p>