$nav_next_id = $page_id + 1;
$sql = "SELECT page FROM plm WHERE id = '$nav_next_id'"; {
$result = mysql_query($sql);
while ($next_page = mysql_fetch_array($result))
{
if($page_id + 1 > 24)
{
$goto_next_page = 'some_page.php';
}
else
{
$goto_next_page = $next_page['page_title'];
}
}
}
Basically a very straight forward next page button on simple site. Using the ID in the MYSQL table I can determine the next page from the current page.
All works well until I come to the last page. Which is page 24.
So i put an if
in the loop saying if the page is > 24 go to some_page.php.
I am echoing $goto_next_page
in my html.
However nothing is echoed from page 24, all other pages work fine. What wrong with this script?
---------UPDATE---------------- THIS IS HOW I GOT IT TO WORK ------------------
if($cur_page_id == 24)
{
$goto_next_page = 'some_page.php';
}
else
{
$sql = "SELECT page FROM plm WHERE id = '$nav_next_id'"; {
$result = mysql_query($sql);
while ($next_page = mysql_fetch_array($result))
{
$goto_next_page = $next_page['page_title'];
}
}
}