Try this:
<?php
$link = mysql_connect( "localhost", "user", "pswd" );
mysql_select_db( "database", $link );
$result = mysql_query( "select * from table", $link );
$num_rows = mysql_num_rows( $result );
if( $num_rows > 0 ) {
mysql_data_seek( $result, $num_rows-1 );
$last_row = mysql_fetch_row( $result );
print_r( $last_row );
mysql_data_seek( $result, 0 );
}
$first_row = mysql_fetch_row( $result );
print_r( $first_row );
$second_row = mysql_fetch_row( $result );
print_r( $second_row );
// ...
?>