> The solution I have been using is to do three queries similar to the below
> SELECT * FROM table WHERE field='ID00025'
> SELECT * FROM table WHERE field<'ID00025' ORDER BY field DESC LIMIT 0,1
> SELECT * FROM table WHERE field>'ID00025' ORDER BY field ASC LIMIT 0,1
> If you whish more row returned change the number in the LIMIT

Why bother with 3 queries?  It's a waste of resources, especially if
you are working with the same record set...

Example (pseudo)code:

<?

    $query = "SELECT * FROM table";
    $result = mysql( $dbname, $query );

   for( $i = 0; $i < mysql_num_rows( $result ); $i++ ) {
     echo "Previous field: " . mysql_result( $result, ( $i - 1 ), "field" );
     echo "Current field: " . mysql_result( $result, $i, "field" );
     echo "Next field: " . mysql_result( $result, ( $i + 1 ), "field" );

    }

?>

Chris


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to