db_query or db_select for getting content type fields Originally I was doing something along the lines of $query = "SELECT {}" and then $result = db_query($query). This method works fine for most of my queries until I needed to get the field values and fid from a specific content type. And then be able to call these values when printing inside HTML. Can anyone provide an example of how I would do this?

I had something along the lines of:

&lt;?php 
$query = "SELECT node.nid AS nid, 'node' AS field_data_field_news_node_entity_type, 'node' AS field_data_field_news_date_text_node_entity_type, 'node' AS field_data_field_news_teaser_node_entity_type, 'node' AS field_data_field_news_body_node_entity_type, 'node' AS field_data_field_news_video_node_entity_type, 'node' AS field_data_field_news_video_image_node_entity_type, 'node' AS field_data_field_mypdf_node_entity_type
    FROM node
    INNER JOIN field_data_field_news_is_featured ON node.nid = field_data_field_news_is_featured.entity_id AND (field_data_field_news_is_featured.entity_type = 'node' AND field_data_field_news_is_featured.deleted = '0')";
?&gt;

$result = db_query($query);

&lt;?php foreach ($result as $row) : ?&gt;

    &lt;div class="featuredArticle"&gt;
        &lt;?php print $row-&gt;field_mypdf_value; ?&gt;
        &lt;?php print $row-&gt;field_mypdf_fid; ?&gt;
    &lt;/div&gt;

&lt;?php endforeach; ?&gt;
If you have your node object, you can use field_get_items to get the field values from the node.

$items = field_get_items( 'node', $node, 'field_name' );
// now $items is an array of values... you can manipulate...
// then use the field_view_value to build the render array
$specific_item = $items[0];
$item_build = field_view_value( 'node', $node, 'field_name', $specific_item );


Here's a link to the field_view_value API doc.

Use the devel module and sprinkle in some dpm()'s to understand the underlying data. It's pretty neat! :)