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 probl开发者_运维技巧em of my code?
You need to
END categories
not two begins.
精彩评论