如果有另一行

I'm trying to write an if statement to check if their is another row after the current one in the database. Where the current one is the id of the page.

<?php if($new_id>id): ?>
yes
<?php else: ?>
no
<?php endif; ?>

$new_id is the selected page. so if their is an entry after it it will say yes, or if it the most recent addition it will say no.

I know how to do this in a select statement: WHERE id>$new_id this tells me if there is another row after it but I don't know how to write it as an IF statement.

Assuming you have a post table with an autoincrementing id field using MySQL:

CREATE TABLE post (
   id       INT NOT NULL AUTO_INCREMENT,
   ...
   PRIMARY KEY ( id )
);

You could use something like this (pseudo-php):

<?php
  // somehow you calculate the current id
  $the_id = your_get_the_id_func();

  // then execute this sql row with your favourite sql library
  // and get the returned single value which may be the stings '0' or '1'
  $has_newer_post = your_exec_sql_and_get_sql_value("
    SELECT EXISTS ( SELECT 1 FROM post WHERE id > $the_id LIMIT 1 );
  ");
?>

<?php
  // if('0') === if(false) only in php: http://codepad.org/IlUx8J1Y
  if( $has_newer_post ) :
?>
  yes
<?php else: ?>
  no
<?php endif; ?>