(assuming your ordered by ID number)
Can you not just have the link take the ID in a variable and do:
$varNew = $varOld + 1;
That way no matter where you are, the link will always go tot he next one.
If you're not ordering by ID nor any other integer then I'm sorry then I cannot help.
Tip: If you want to make the integer orderin ascending or descending -- use an IF statement within the link as I described above.
Note: This is not valid code
if $order == "a" then //checking if the ordering is ascending: 1, 2, 3.
Next does this: $varNew = $varOld + 1
Previous does this: $varNew = $varOld - 1
ElseIf $order == "d" then //checking to see if order is descending: 3, 2, 1.
//The same happens if ordered descending. This will happen if the $order is NOT ascending but DESCENDING.
Next does this: $varNew = $varOld - 1
Previous does this: $varNew = $varOld + 1
Else //This would be the 'default' order setting or if it's ordered by another column.
[ENTER text here to order using other means.]
Wow that was messy but I hope you understood it.