DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Michael has posted 27 posts at DZone. View Full User Profile

Next & Previous Records

08.08.2007
| 949 views |
  • submit to reddit
        // finds the previous record and next record id


$previous_sql = mysql_query("SELECT MAX(csr_id) csr_id FROM csr_entry WHERE (csr_id<'$csr_id')") or die (mysql_error());
$previous_record = mysql_result($previous_sql,"csr_id");

$next_sql = mysql_query("SELECT MAX(csr_id) csr_id FROM csr_entry WHERE (csr_id>'$csr_id')") or die (mysql_error());
$next_record = mysql_result($next_sql,"csr_id");