How to output all rows in a database with smarty ?
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}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With