Well, the page "number", as it were, could be represented by:
$pagenum=(int) (str_replace(".html", "", $_SERVER['SCRIPT_FILENAME']));
$next=$pagenum+1;
$last=$pagenum-1;
echo "Next: $next, Last: $last, this one is $pagenum";
I'm sure you can create links from that ...
As to your other ??, how about using [man]file_exists/man?