Im a "noob" in smarty. I need to execute following code in one of my .tpl files:
<? // 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->num_rows > 0) {
// output data of each row from $result
while($row = $result->fetch_assoc()) {
echo '<tr>
<td><a href="http://www.site.com/forum.php?topic='. $row['id']. '">'. $row['title']. '</a> </td>
</tr> ';
}
}
else {
echo 'No news';
}
?>
I've been trying for 3 hours now, surfing all over the web but without success. Help please!
$smarty->assign()the rows fetched to an array which gets used in the template.{include file='newsacc.php'}but I guess it's wrong. I have no "smarty" idea whatsoever. I have this script which uses smarty and just want to add this widget. Any good examples about what you are saying? Thanks