// First lets get the query $jokeNo = $_GET["j"]; if( ! $answers = fopen( "answers.txt", "r" ) ) { echo "An error has occured - answers not found!"; return; } $i = 1; while( !feof( $answers ) ) { $a = fgets( $answers, 256 ); if( $i == $jokeNo ) { echo "$a"; fclose( $answers ); return; } ++$i; } fclose( $answers ); echo "The answer was not found to that joke"; ?> |