I extracted records from the database and assigned them to the variable $results
and I'm trying to loop through this array of objects but can't access anything in the objects and it only runs once despite there being 3 objects.
Here is what I get from var_dump($results);
:
array(3)
{
[3]=> object(stdClass)#261 (3) {
["id"]=> string(1) "3" ["grade"]=> string(1) "A" ["score"]=> string(2) "95" }
[2]=> object(stdClass)#260 (3) {
["id"]=> string(1) "2" ["grade"]=> string(1) "A" ["score"]=> string(2) "90" }
[1]=> object(stdClass)#259 (3) {
["id"]=> string(1) "1" ["grade"]=> string(1) "C" ["score"]=> string(2) "50" }
}
Here is what I'm trying in the mustache template:
<table>
<tr>
<th>Score</th>
<th>Grade</th>
</tr>
{{#results}}
<tr>
<td>{{ score }}</td>
<td>{{ grade }}</td>
</tr>
{{/results}}
</table>