P. Nick P. Nick - 1 month ago 5
PHP Question

PHP - Latte template foreach property of non-object

I'm currently using Latte to do things.
What I can't figure out is how to use a foreach loop on a query with it's template variables. My code below would always return in

Trying to get property of non-object

$query = $this->db->query("SELECT id FROM table");
$array = array();
$fetch = $query->fetch_array();
$array[] = $fetch;

$Template["qclisting"] = $array;

And the template code

{foreach $qclisting as $item}
<a href="" class="list-group-item clearfix">
<span class="clear">


In your template, use


...instead of...


And, remove the [] from line 4 of your code:

$array = $fetch;