I am trying to loop through my array which contains objects and print out the data I need into my HTML. This HTML needs to print my first element and afterwards "create" a new HTML showing my second element and so on...
This is my PHP function where I query the DB:
public function getCuponesUser(){
$db = JFactory::getDbo();
$user = JFactory::getUser()->id;
$query = 'SELECT * FROM #__cuphoneo_subscripcion as cs LEFT JOIN #__k2_items as k2i ON k2i.id = cs.item_id WHERE cs.user_id='.$user.' GROUP BY cs.item_id';
$db->setQuery($query);
$resultado = $db->loadObjectList();
return $resultado;
}
This is what $resultado
returns: http://pastebin.com/PSX7KMBq
And this is my HTML/PHP code where I am trying to print the data retrieved:
<div class="panel-group" id="accordion">
<div class="panel panel-info">
<?php
$model = $this->getModel();
$cuponesUsuario[] = $model->getCuponesUser();
foreach($cuponesUsuario as $valor){
?>
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" data-target="#collapse1">
<div class="panel-heading-left">
<h4 class="panel-title accordion-toggle">
Data 1
</h4>
</div>
<div class="panel-heading-right">
<h4 class="panel-title">
Data 2
</h4>
</div>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
<div class="panel-left">
<div class="panel-image">
Data 3
</div>
<div class="panel-fecha">
<span class="label label-info">Data 4</span>
</div>
</div>
<div class="panel-right">
<div class="panel-desc">
Data 5
</div>
<div class="panel-boton-canjear">
<input class="btn" type="button" value="Canjear"/>
</div>
</div>
</div>
</div>
<?php } ?>
Where it says Data 1, Data 2, Data 3...etc, is where I need to print out the different values the Query may return.
EDIT: Im pretty sure I also have to use a for
but not very sure how to do this :P