通常、次のようにデータベースからデータを取得して返します。
$sql = "SELECT * FROM users";
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res)) {
echo $row['id'];
echo $row['name'];
}
しかし、Smarty を使用してデータを返す方法は?
私は、割り当てなければならないと思います$row
:
$smarty->assign('row', $row);
$smarty->display('search.tpl');
しかし、実際に表示する方法がわかりません。これは機能しません:
{foreach from=$row item=item}
{$item}
{/foreach}