Codeigniter view file looping query
- by user2505513
Right, I'm unsure about how to code my view file to generate following query results WITHOUT compromising the principles of mvc.
Query in model:
SELECT * FROM events GROUP BY country, area ORDER BY country, area
View:
<?php if (isset($query)):?>
<?php foreach ($query as $row):?>
<h2><?=$row->country?></h2>
<h3><?=$row->area?></h3>
<?php endforeach;?>
<?php endif;?>
I want the results to display:
England
North
South
West - utilising the GROUP BY parameter
As opposed to:
England
North
England
South
England
West
Has anybody any advice as to how to achieve this?