PEAR 错误“找不到块‘类别’” ”
我刚刚接触 PEAR 编程。 当尝试使用 SIGMA 模板将数据从数据库传递到 html 时,我遇到了问题。这里的代码:
$tpl->loadTemplateFile('content_index_form.html');
$csql = "SELECT a.*
FROM `dod_cat` a
LEFT JOIN `dod_brand` b ON b.sID = a.sID
WHERE a.status =1
GROUP BY a.sID";
$result_category = $mdb2->query($csql);
if (MDB2::isError($result_category)) {
die ("Error: ".$result_category->getMessage()." <br>Query:".$csql."<br>");
}
$y=0;
while($row_category = $result_category->fetchRow()){
$y++;
$tpl->setVariable(array(
'cat_id' => $row_category['sID'],
'cat_name' => $row_category['name'],
'cat_equ' => $row_category['equ_name'],
));
$tpl->parse('categories');
}
$tpl->show();
下面是模板代码:
<table>
<!-- BEGIN categories -->
<tr>
<td><a href="{cat_id}">{cat_name} ({cat_equ})</a></td>
</tr>
<!-- BEGIN categories -->
</table>
这是 html 页面上显示的错误行“找不到块'类别'”。有人知道我的代码有什么问题吗?
I just new in PEAR programming.
I got a problem when try to passing data from database to html with SIGMA templating. Here the code :
$tpl->loadTemplateFile('content_index_form.html');
$csql = "SELECT a.*
FROM `dod_cat` a
LEFT JOIN `dod_brand` b ON b.sID = a.sID
WHERE a.status =1
GROUP BY a.sID";
$result_category = $mdb2->query($csql);
if (MDB2::isError($result_category)) {
die ("Error: ".$result_category->getMessage()." <br>Query:".$csql."<br>");
}
$y=0;
while($row_category = $result_category->fetchRow()){
$y++;
$tpl->setVariable(array(
'cat_id' => $row_category['sID'],
'cat_name' => $row_category['name'],
'cat_equ' => $row_category['equ_name'],
));
$tpl->parse('categories');
}
$tpl->show();
Below is template code:
<table>
<!-- BEGIN categories -->
<tr>
<td><a href="{cat_id}">{cat_name} ({cat_equ})</a></td>
</tr>
<!-- BEGIN categories -->
</table>
And this is the error line "Cannot find block 'categories'" show on html page. Is it anybody know what the problem of my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要的
不是两个开始。
You need to
not two begins.