[eluser]Bionicjoe[/eluser]
I'm using num_rows() to check for results, and that is working.
However I would like to use the result to number each line of data returned.
My function may get 4 rows and I would like them displayed in reverse order as follows:
Update 4: BlahBlahBlahBlah
Update 3: BlahBlahBlah
Update 2: BlahBlah
Update 1: Blah
The MVC I have gets the right data, and sorts it correctly, but I can't figure out how to number it.
Model
Code:
function listoutageupdates($id)
{
$this->db->order_by("updateid", "desc");
$query = $this->db->get_where('updates', array('outageid' => $id));
$num = $this->db->count_all('updates');.
if ($query->num_rows() > 0)
{
return $num->result();
return $query->result();
}
if ($query->num_rows() == 0)
{
//TO BE ADDED LATER: Return a no results found message.
return FALSE;
}
}
View
Code:
if ($updates):
foreach ($updates as $update)
{
?><table id="outageform">
<col />
<tr><td>Update <?php echo $update->num; ?></td><td><?php echo $update->text;?></td></tr>
<?php
}
else:
?><table id="outageform">
<col />
<tr><td></td><td><b>No updates found.</b></td></tr>
<?php endif; ?>
</table>