简体   繁体   English

PHP smarty数据库输出

[英]PHP smarty database output

如何使用smarty输出数据库中的所有行?

Basically, read the database data in a "controller" or something like that and send them to smarty using a variable, much like this: 基本上,在“控制器”或类似的东西中读取数据库数据,并使用变量将它们发送到smarty,就像这样:

$db = GetSomeDbObject();

$rows = $db->Query("Select * From aTable");
$smarty->assign("rows", $rows);
$smarty->display("index.tpl");

And, now in a smarty file (index.tpl) 而且,现在在一个聪明的文件(index.tpl)

<h2>Smarty Rows</h2>
{foreach $rows as $row}
  Row Name: {$row.FieldName}
{/foreach}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM