How to populate DB values in content type field, drupal 7 I have created a content type with 4 field in Drupal 7. One field is of list type, say for listing countries. I have tables in DB for saving country_id and country_name. Is there any way to connect the DB table and content type field? I want to list all these countries in the content type's country field.
You have to install Content Construction Kit (CCK) module. After installing this module you get a text field for Allowed value function in field setting of desired field. Put the function name here to get country list. Also put following function in a module.  You may have to modify query as per your requirement.  After doing all these thing you will able to get country list in that field.



function _get_country_list(){
    $country = array(); 
    $query = db_select('country', 'c');
    $query-&gt;fields('c', array('country_name','country_id'));
    $result = $query-&gt;execute();    
    if ($result) {
        while ($row = $result-&gt;fetchObject()) {
            $country[$row-&gt;country_id] = t($row-&gt;country_name);
        }
    }
    return $country;
}