CodeIgniter Forums
Get next row in mysql results - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Get next row in mysql results (/showthread.php?tid=47615)



Get next row in mysql results - El Forum - 12-15-2011

[eluser]Unknown[/eluser]
I was just wondering if there is a way to get the next row in advanced when looping through a mysql results. At the moment I have

Code:
<? $i=1; ?>
<? foreach ($query->result() as $row): ?>
    
    <?= $row->order_id ?>

<? $i++; ?>
<? endforeach; ?>

At the moment this just echo's the order_id in the row its currently looping through but is there a way to get the order_id of the next row in advance?

The reason I want to do this is because if I know the order_id is going to change on the next row then I will want to echo something different.

Thanks