Welcome Guest, Not a member yet? Register   Sign In
[solved] help with syntax for result set
#3

[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


Messages In This Thread
[solved] help with syntax for result set - by El Forum - 11-25-2008, 04:07 PM
[solved] help with syntax for result set - by El Forum - 11-25-2008, 04:40 PM
[solved] help with syntax for result set - by El Forum - 11-26-2008, 09:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB