I have taken the working code from this thread: Creating Next and Previous buttons for navigation
It works for me but right now I would like to ask is there any way to disable the link if it reaches the 1st or the last ID?
Here's my brief code:
function getNavID($id) {
$result4= mysql_query("SELECT
( SELECT id FROM products_list WHERE id > '$id' LIMIT 1 )
AS nextValue,
( SELECT id FROM products_list WHERE id < '$id' ORDER BY id DESC LIMIT 1 )
AS prevValue
FROM products_list");
if ($resultID = mysql_fetch_array($result4)) {
return $resultID;
}
else {
return NULL;
}
}
$LinkID = getNavID($id);
<p><a href="update.php?id=<?php echo urlencode($LinkID['prevValue']); ?>">Previous</a></p>
<p><a href="update.php?id=<?php echo urlencode($LinkID['nextValue']); ?>">Next</a></p>
Let's say the page I'm on now is ID=1 so logically, there is no ID lesser than 1. Is there any way that I can do to disable the links if the ID reaches the min and max ID ?
Thanks in advance guys.
Regards, Jeff