I have associative array:
Model
public function selectArticle(){
$sql = $this->db->query("SELECT * FROM articles");
return $sql->result_array();
}
Controller
public function index(){
$data['articles'] = $this->article->selectArticle();
$this->parser->parse('index.tpl', $data);
}
Template
{foreach from = $articles item = $article}
<tr>
<td width="30%">{$article.title}</td>
<td width="30%">
<a href="{$article.link}" target="_blank">http://example.net</a>
</td>
<td width="20%">{$article.size}</td>
<td width="20%">{$article.count}</td>
</tr>
{/foreach}
How get fild in template?
As now: article.fild – not work
remove $article, have to use article
Try this code: