{foreach from=$DB_RESULTS item="foo_q"}
| id: {$foo_q->id} | Name: {$foo_q->name} |
| No items were found in the search |
前台赋值index.php
$smarty->assign('DB_RESULTS',$db->get_results("select link_id id,link_name name from wp_links"));
mytemplate.tpl 内容如下
<table border="0" cellspacing="0" cellpadding="3">
{foreach from=$DB_RESULTS item="foo_q"}
<tr>
<td>id: {$foo_q->id}</td>
<td>Name: {$foo_q->name}</td>
</tr>
{foreachelse}
<tr>
<td>No items were found in the search </td>
</tr>
{/foreach}
</table>
本文详细解析了如何使用模板和Smarty引擎实现搜索结果的显示,包括数据获取、模板赋值及展示逻辑。

360

被折叠的 条评论
为什么被折叠?



