title: Codeigniter auto suggestion text box
body: <p>I'm using codeigniter in my project and want to implement a text box which suggests related word s from the data base. In this one I want to get the ID of the selected vehicle. But so far I was only able to retrieve the vehicle names with out IDs.</p>
  
  <p>The code so far,</p>
  
  <p>Model</p>
  
  <pre><code>function searchVehicle($name){
          $this-&gt;db-&gt;like('Name', $name, 'both');
          return $this-&gt;db-&gt;get('vw_vehicle_search')-&gt;result();
      } 
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>public function vehicle_search(){
          $this-&gt;load-&gt;model('model_vehicle');
          if(isset($_GET['term'])){
              $result = $this-&gt;model_vehicle-&gt;searchVehicle($_GET['term']);
              if(count($result)&gt;0){
                  foreach($result as $object)
                      $arr_result[] = $object-&gt;Name;
  
                  echo json_encode($arr_result);
              }
          }
      }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
              $(document).ready(function(){
                  $('#vehicle_name').autocomplete({
                      source: "&lt;?php echo base_url();?&gt;vehicle/vehicle_search/?"
                  });
              });
          &lt;/script&gt;
  
      &lt;div class="col-md-4"&gt;
          &lt;?php
          $input_data = array(
          'name'  =&gt; 'vehicle_name',
          'id' =&gt; 'vehicle_name',
          'class' =&gt; 'form-control'
          );
          echo form_input($input_data)?&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>How can I pass the id of the vehicle with this one and get the id when i select a vehicle to insert to the db.
  Thank you.</p>