Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8244597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:54:26+00:00 2026-06-07T21:54:26+00:00

$nav_next_id = $page_id + 1; $sql = SELECT page FROM plm WHERE id =

  • 0
$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'];
    }
}
}   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:54:30+00:00Added an answer on June 7, 2026 at 9:54 pm

    Perhaps you meant to use the pre-increment operator:

    if(++$page_id > 24)
    

    Effectively, this means:

    $page_id = $page_id + 1;
    
    if($page_id > 24) {
    

    This operator as well as its brother operator (the post-increment operator) both add 1 to the variable. However, the pre-increment operator adds one and then returns the new value. The post-increment operator, on the other hand, returns the value of the variable and then increments it by 1.

    The reason why your code doesn’t work is that $page_id + 1 > 24 doesn’t increment $page_id so it always remains the same. This makes sense because if you did:

    $a = $page_id + 1;
    

    You wouldn’t expect $page_id to be incremented. You would expect $a to be 1 more than $page_id, but you’d expect $page_id to be the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page template in wordpress that only shows posts from a specific
I've set up a WordPress navigation for my single.php template that gets the previous
I have a form with following fields.While click on submit button I am getting
I have some JS on my site that should prevent the following code from
I have a series of photos on a page in an unordered list. I
I use this jQuery slide show http://css-tricks.com/moving-boxes/ in my page but the problem in
I'm wondering why my aside is at the bottom of the page instead of
I am returning XML data from the Yahoo GeoPlanet web service using HttpWebRequest .
I've setup the cycle plugin to work multiple times on one page, which is
The problem On my page, when a specified <a> is clicked upon, another part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.