i'm not that good with php, but I did the code below and hope for some little help:
<?php
$next = '';
$result = mysql_query("SELECT ID FROM table WHERE x_column < '$x_column_variable' AND Column = '$column_variable' ORDER BY x_column DESC LIMIT 1");
while($row=mysql_fetch_array($result)) {
$next_id = $row['ID'];
if ($next_id != '') {
$next = '<a href="****.php?id='.$next_id.'"><img src="img/next.jpg"/></a>';
}
}
?>
The code works but when i have multiple ids with the same x_column value, it gives me only the first one and jump to the next x_column value.
Ex: if i have
12 78 2 2 1
i get only
78 12 2 1