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:
<?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')";
?>
$result = db_query($query);
<?php foreach ($result as $row) : ?>
<div class="featuredArticle">
<?php print $row->field_mypdf_value; ?>
<?php print $row->field_mypdf_fid; ?>
</div>
<?php endforeach; ?>