Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Prev Cat / Next Cat / First / Last Cat

Quote Reply
Prev Cat / Next Cat / First / Last Cat
To fetch the prev cat i use in php

SELECT * FROM Category
WHERE Name < ( SELECT Name FROM Category WHERE CategoryID = $catid )
ORDER BY Name DESC limit 0,1

To fetch the next cat

SELECT * FROM Category
WHERE Name < ( SELECT Name FROM Category WHERE CategoryID = $catid )
ORDER BY Name ASC limit 0,1


Unfortunately i have no idea how to tell this to LSQL.


Then i have to check, if a cat is the last or the first one, because the prev to the first should be the last, the next to the last one should be the first one.

Is there any solution for this, please?


Hmmm, i just understand that i still have the name.

Then i should maybe ask:

SELECT * FROM Category
WHERE Name < $name
ORDER BY Name ASC limit 0,1

I will try it in a minute ...
Subject Author Views Date
Thread Prev Cat / Next Cat / First / Last Cat Robert 3383 May 25, 2016, 8:44 AM
Thread Re: [Robert] Prev Cat / Next Cat / First / Last Cat
Andy 3300 May 26, 2016, 3:15 AM
Post Re: [Andy] Prev Cat / Next Cat / First / Last Cat
Robert 3276 May 26, 2016, 7:31 AM