title: How to put data from the database to the template
body: <p>I want to put data from my database into my template file. This data will be selected based on user id. </p>
  
  <p>I have the template file set up and I have the code to select a user based on their id, what I don't know and have been unable to work out is where the code that selects the data needs to be placed i.e. block, helper etc...</p>
  
  <p>I assume its needs to go in a block, from there I don't know how I would get the data to the template and place each piece of data into their respective input fields?</p>
  
  <p>my questions are:</p>
  
  <ul>
  <li>where would the code go</li>
  <li>how do I call that code from the template</li>
  </ul>
  
  <p>===EDIT===</p>
  
  <p>Namespace/Module/Block/Blockname.php</p>
  
  <pre><code>class Namespace_Module_Block_Blockname.php
  extends Mage_Core_Block_Template
  {
  public function postsGetByIdAction($id)
  {
      $params = $this-&gt;getRequest()-&gt;getParams();
      $prefs = Mage::getModel('module/model');
      $prefs-&gt;load($params['id']);
      $data = $prefs-&gt;getData();
      return$data;
  }
  }    
  </code></pre>
  
  <p>template/namespace/module/templatefile.phtml</p>
  
  <pre><code>&lt;?php echo $this-&gt;postsGetById(); ?&gt;//returns invalid method Mage_Core_Block_Template::postsGetById(Array())
  </code></pre>
  
  <p>I have tried var_dump as the error message said 'array' at the end but I still get the same message</p>