title: Code Igniter - form_dropdown selecting correct value from the database
body: <p>Im having a few problems with the form_dropdown function in CodeIgniter .... My application is in 2 parts, a user goes in, enters a form and submits it .... once its submitted a admin can go in and edit that persons form and then save it to database.</p>
  
  <p>So, to display the dropdown in the initial form, im using the following ( all the options in the dropdown are coming from the database )</p>
  
  <p>Model:</p>
  
  <pre><code>    function get_salaries_dropdown()
  {
      $this-&gt;db-&gt;from($this-&gt;table_name);
      $this-&gt;db-&gt;order_by('id');
      $result = $this-&gt;db-&gt;get();
      $return = array();
      if($result-&gt;num_rows() &gt; 0){
              $return[''] = 'please select';
          foreach($result-&gt;result_array() as $row){
              $return[$row['id']] = $row['salaryrange'];
          }
      }
      return $return;
  }
  </code></pre>
  
  <p>Then in the Controller:</p>
  
  <pre><code>$data['salaries'] = $this-&gt;salary_expectation-&gt;get_salaries_dropdown();
  </code></pre>
  
  <p>Then finally the View:</p>
  
  <pre><code>&lt;?php echo form_dropdown('salaries', $salaries, set_value('salaries', $salaries));  ?&gt;
  </code></pre>
  
  <p>That bit works perfect in displaying the dropdown filled with values for the user to select.</p>
  
  <p>So, when the user selects a value, then hits save, its saved to the database.</p>
  
  <p>On the Edit page which the admin see's, im using the same code to display the dropdown filled with options, but how do i get it to automatically choose the one thats been selected by the user in the initial stage?</p>
  
  <p>Cheers,</p>