title: Codeigniter how to get an id from current selected record
body: <p>I have this <strong>package</strong> table:</p>
  
  <pre><code>+----+--------------+
  | id | package_name |
  +----+--------------+
  |  1 | simple       |
  |  2 | elegant      |
  +----+--------------+
  </code></pre>
  
  <p>and this <strong>brochure</strong> table:</p>
  
  <pre><code>+----+------------+-------------+
  | id | package_id |    image    |
  +----+------------+-------------+
  |  1 |          1 | simple.jpg  |
  |  2 |          2 | elegant.jpg |
  +----+------------+-------------+
  </code></pre>
  
  <p>And then I looped the <strong>package table</strong> record to generated list for tab like so:</p>
  
  <pre><code>&lt;div class="tabbable tabs-left"&gt;
    &lt;ul class="nav nav-tabs"&gt;
      &lt;li class="active"&gt;
        &lt;a href="#package_1" data-toggle="tab"&gt;
          Simple                
        &lt;/a&gt;
      &lt;/li&gt;
      &lt;li class=""&gt;
        &lt;a href="#package_2" data-toggle="tab"&gt;
          Elegant                
        &lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
    &lt;div class="tab-content"&gt;
      &lt;div class="tab-pane active" id="package_1"&gt;
        &lt;div class="col-xs-3" id="package-detail"&gt;            
  
        &lt;/div&gt;
  
        &lt;div class="col-xs-7" id="brochure_1"&gt;
          &lt;!-- SHOW BROCHURE IMAGE BY PACKAGE ID HERE --&gt;
  
          &lt;!-- END --&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="tab-pane " id="package_2"&gt;
        &lt;div class="col-xs-3" id="package-detail"&gt;
  
        &lt;/div&gt;
  
        &lt;div class="col-xs-7" id="brochure_2"&gt;
          &lt;!-- SHOW BROCHURE IMAGE BY PACKAGE ID HERE --&gt;
  
          &lt;!-- END --&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want tho display <strong><em>image</em></strong> from <strong>brochure table</strong> based on <strong><em>id</em></strong> from <strong>package table</strong> triggered by selected tab list and put the image between this tag:</p>
  
  <pre><code>&lt;div class="col-xs-7" id="brochure_2"&gt;
    &lt;!-- SHOW BROCHURE IMAGE BY PACKAGE ID HERE --&gt;
  
    &lt;!-- END --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and this is my controller</p>
  
  <pre><code>$this-&gt;load-&gt;model('admin/package_model', 'package');
  // SELECT ALL DATA FROM PACKAGE TABLE
  $this-&gt;data['packages'] = $this-&gt;package-&gt;get();
  
  $this-&gt;load-&gt;model('admin/brochure_model', 'brochure');
  // GET DATA FROM BROCHURE TABLE WHERE PACKAGE_ID = ID (FROM PACKAGE TABLE FROM     SELECTED TAB)
  $this-&gt;data['brochures'] = $this-&gt;brochure-&gt;get_by(array(
    'package_id' =&gt; ID VARIABEL FROM SELECTED TABS'
  ));
  
  $this-&gt;load-&gt;view('frontend/page/package', $this-&gt;data);
  </code></pre>
  
  <p>Thank you before</p>