title: PHP database (sql) query in smarty tpl
body: <p>Im a "noob" in smarty. I need to execute following code in one of my .tpl files:</p>
  
  <pre><code>  &lt;? // SELECT sql query
  $sql = "SELECT 'id' , 'title' FROM `forum_posts` WHERE bid = '1' ORDER BY 'date' DESC LIMIT 4"; 
  
  // perform the query and store the result
  $result = query($sql);
  
  // if the $result contains at least one row
  if ($result-&gt;num_rows &gt; 0) {
    // output data of each row from $result
    while($row = $result-&gt;fetch_assoc()) {
      echo '&lt;tr&gt;
          &lt;td&gt;&lt;a href="http://www.site.com/forum.php?topic='. $row['id']. '"&gt;'. $row['title']. '&lt;/a&gt;  &lt;/td&gt;  
          &lt;/tr&gt;   ';
    }
  }
  else {
    echo 'No news';
  }
  ?&gt;
  </code></pre>
  
  <p>I've been trying for 3 hours now, surfing all over the web but without success. 
  Help please!</p>