[eluser]Dave Rau[/eluser]
I ended up with this:
controller:
Code:
$data['nextprev'] = $this->simple_gallery->get_nextprev($this->uri->segment(3), $this->uri->segment(4));
view:
Code:
$next_id = $nextprev->row('next_id');
$prev_id = $nextprev->row('prev_id');
If someone is making a photo gallery here's a GREAT query for next/previous links in an specific order. I have albums and I'm sorting by ID, so the newest images are first in the list and you go backwards in time to see other images in the album. Here's the query:
Code:
SELECT id, title, @a := id, ( SELECT id FROM gallery WHERE album = '$album' AND id < @a ORDER BY id DESC LIMIT 1 ) AS prev_id, ( SELECT id FROM gallery WHERE album = '$album' AND id > @a ORDER BY id ASC LIMIT 1 ) AS next_id FROM gallery WHERE album = '$album' and id = '$id' order by id