title: select id from the select gender dropdown list
body: <p>I have a dropdown list of gender. I am getting the values from my table 'candidate' and in this table i have a field which is actually a foreign key to another table.</p>
  
  <p>The field is gender_code_cde, and the table name is gender_code. Now gender_code contains 2 rows. and id and a description. Its structure is like:</p>
  
  <p>1->Male
  2->Female</p>
  
  <p>Its being displayed in dropdown list. but I want to get the id 1 if male is selected and id 2 if female is selected. My code is below: </p>
  
  <pre><code>&lt;p&gt;
  &lt;label for ="gender"&gt;Gender:&lt;/label&gt;
  &lt;?php
     $query = mysql_query("select * from gender_code"); // Run your query
     echo '&lt;select name="GENDER"&gt;'; // Open your drop down box
     //Loop through the query results, outputing the options one by one
     while ($row = mysql_fetch_array($query)) 
    {
       echo '&lt;option value="'.$row['gender_cde'].'"&gt;'.$row['gender_dsc'].'&lt;/option&gt;';
    }
    echo '&lt;/select&gt;';
  ?&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>I am working in codeIgniter. </p>