title: Passing variables from template.php to page.tpl
body: <p>I'm very new to drupal and i need to query a table and pass a result from that query to my page.tpl file as a variable. Ive tried for hours but nothing i find works. </p>
  
  <p>php code in template.php</p>
  
  <pre><code>&lt;?php
   $result = db_select("SELECT COUNT(node.nid) AS num FROM node WHERE node.type = 'service'");
   foreach ($result as $record) {
      $number = $record-&gt;num;
   }
   return $number;
  </code></pre>
  
  <p>I even tried adding an <code>echo 'hello world';</code> but that didnt show up either. </p>
  
  <p>Code in page.tpl </p>
  
  <pre><code> &lt;?php if ($number &gt; 0) { ?&gt;
      testing
   &lt;?php } ?&gt;
  </code></pre>
  
  <p>There are two nodes with the type as service. Any help would be great. thanks. </p>