Q:

Show mysql query using Smarty php

I'm making a blog as a school project and is a bit stuck.
One of the requirements for the project is to use smarty, and this is totally new to me.
My problem is that I want to assign the "blog-posts" from my database to smarty variables. 
My approach is like this:  
<?php
require_once('connect_db.php');
$result = $db->query("SELECT * FROM Innlegg");
while ($row = $result->fetch_assoc())
{print ("<h1>" . $row["forfatter"] . "</h1>");
print ($row["innhold"]);}
?>

Now i just print out "forfatter" from "Innlegg". How is this done by using smarty?

A:

Try reading the Smarty FAQ first.. its very straightforward 
$list=array();
while ($row = $result->fetch_assoc()) {
    $list[]=$row;
}

$smarty = new Smarty(); //maybe some configuration ?
$smarty->assign('list', $list);
$smarty->fetch('index.tpl');

and inside smarty index.tpl template file
{foreach from=$list item=row}
    <h1>{$row.forfatter}</h1>
    {$row.innhold}
{/foreach}

