title: Selected as Selected Database value Codeigniter
body: <p>In user edit module have a dropdown in which i show options from database.</p>
  
  <p>Now i select a value from dropdown and want to set it as selected.
  SO next time when i edit user i can see which was the last value selected.</p>
  
  <p>When i edit a user i select some value from dropdown, and then save the record back to database. Next time when i open that record i want the option i selected last time to be shown selected.</p>
  
  <p>I tried this : </p>
  
  <pre><code>&lt;tr&gt;
      &lt;td&gt;Base INI File&lt;/td&gt;
        &lt;?php 
  
      if(isset($_GET['id'])) 
      { 
      $id=$_GET['id']; 
      btn_edit_file($id); 
      } 
      ?&gt;  
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; 
  
  
      &lt;td&gt; 
          &lt;select required name="base_ini_id" id="base_ini_id" class="form-control"&gt; 
  
          &lt;option value=""&gt;Select&lt;/option&gt; 
          &lt;?php foreach($base as $value) { ?&gt; 
          &lt;option id="emp" class="specialLink" value="&lt;?php echo $value-&gt;id;?&gt;"&gt;&lt;?php echo $value-&gt;base_ini_filename;
            if($value-&gt;id == $value-&gt;base_ini_filename){echo "selected='selected'";}  ?&gt; &lt;/option&gt; 
          &lt;?php } ?&gt; 
          &lt;/select&gt; 
      &lt;/td&gt; 
  
  
      &lt;td&gt; 
  
      &lt;?php echo btn_edit('customer/upload_ini/edit_ini_custom/'); ?&gt; 
      &lt;/td&gt; 
  
  
      &lt;script type="text/javascript"&gt; 
              $(document).ready(function() { 
                  $('#base_ini_id').change(function() { 
                      var id = $("#base_ini_id").val();
                      var url = "/bizrtc/customer/upload_ini/edit_ini_custom/";
  
                      $("#edit_link").attr("href",url+ id); 
                      $("#edit_link").attr("target","_blank");
  
                  }); 
              }); 
          &lt;/script&gt;
       &lt;/tr&gt;
  </code></pre>