How to output all rows in a database with smarty ?
1 Answer
Basically, read the database data in a "controller" or something like that and send them to smarty using a variable, much like this:
$db = GetSomeDbObject();
$rows = $db->Query("Select * From aTable");
$smarty->assign("rows", $rows);
$smarty->display("index.tpl");
And, now in a smarty file (index.tpl)
<h2>Smarty Rows</h2>
{foreach $rows as $row}
Row Name: {$row.FieldName}
{/foreach}