[eluser]pickupman[/eluser]
I was trying to do this in the past. What you are looking to do is a pivot table. Pivot tables are not easily done in php and mysql, and especially in CI/active record syntax. I have done in the past, I decided how many columns I want, iterate through the results, and add cells to an indexed array like col1, col2, col3. Then work through cells accordingly. You might find it usefully to create a nested table.
[code]
//In Controller
$results = $result->result(); //Save result object from model
$i = 0;
$data['col1_cell'] = array();
$data['col2_cell'] = array();
$data['col3_cell'] = array();
foreach($results as $row){
if($i%2 == 0 && $i == 6)
$data['col2_cell'][] = array('icon' => $row->icon, 'text' => $row->text);
elseif($i%3 == 0)
$data['col3_cell'][] = array('icon' => $row->icon, 'text' => $row->text);
else
$data['col1_cell'][] = array('icon' => $row->icon, 'text' => $row->text);
}
//Now loop through each cell to create a table. You may to create a view to do this.
$data['col1'] = $this->load->view('pivot_table', $data, TRUE); //Build col1
$data['col2'] = $this->load->view('pivot_table', $data, TRUE); //Build col2
$data['col3'] = $this->load->view('pivot_table', $data, TRUE); //Build col3
$this->load->view('final_view', $data); //Load page
//In final_view
<table>
<tr>
<td id="col1"><?=$col1;?></td>
<td id="col2"><?=$col2;?></td>
<td id="col3"><?=$col3;?></td>
<tr>
</table>
</code]
It was a huge pain in the ***. This example is perfect, but that was off the top of my head. Obviously using 2 & 3 as a modulus would cause a problem so you would have to extend the syntax to accommodate for common multiples of 2&3.