[eluser]josepichu[/eluser]
Hi!
I have a problem using CI with Twig Template engine.
I want to show my DB results into my views.
i have do it (i simplify it):
Code:
My Controller
function index() {
$data['data'] = $this->my_model->show_results();
$this->twig->display('layout.php', $data);
}
Code:
My Model
function show_results() {
$sql="select * from my_table";
$result = mysql_query($sql);
while ($row = mysql_fetch_Array($result)) {
$data = array( array('param1' => 'value1',
'param2' => 'value2'));
}
return $data;
}
Code:
My view - layout.php
<ul>
{% for dat in data %}
<li> {% dat.param1 %} </li>
{% enfor %}
</ul>
I want to show all the query results, with my code i only show the last row of my query.
Help please!