Where to place PHP code for a node if not in the node body block itself?
One of two places, hook_node_view() or hook_preprocess_node(). They can both be used in a module file, but only the latter will work in your theme's template.php file.

hook_node_view() example:

function MYMODULE_node_view($node, $view_mode, $langcode) {
  if ($node-&gt;type == 'my_node_type') {
    $args = array(':nid' =&gt; $node-&gt;nid);
    $my_value = db_query('SELECT my_field FROM {my_table} WHERE nid = :nid', $args)-&gt;fetchField();

    $node-&gt;content['my_value'] = array(
      '#markup' =&gt; 'My value is: ' . $my_value, 
      '#weight' =&gt; 10 // Controls the display order of this piece of content
    );
  }
}


hook_preprocess_node() example:

function MYMODULE_preprocess_node(&amp;$vars) {
  $vars['content']['my_additional_field'] = array(
    '#markup' =&gt; $additional_field, 
    '#weight' =&gt; 10, 
    '#theme' =&gt; 'mymodule_my_additional_field',
  );
}