webcomic navigation php script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

hello, i am wondering if someone can help me code something relatively
simple for navigating through a linear series of php pages. my code is
halfway done, and is basically functional, but i would like to add
something to it. the code right now can find what page you are on, the
next page, and the previous page. here is how it currently reads:

<? //to get filename
    $parts = Explode('/', $p);
    $p = $parts[count($parts) - 1]; //get filename
  $c = strtok($p,".");  //get number string

  $nc = $c+1; //next comic
  $pc = $c-1; //previous comic

  $ncf = "$nc.php"; //next comic filename
  $pcf = "$pc.php"; //previous comic filename

   if (file_exists($ncf)) {
     echo "<a href=\"$ncf\">go to the next page</a>";
   else {
     echo "<a href=\"0.php\">go to the first page</a>";
<br />
   if (file_exists($pcf)) {
     echo "<a href=\"$pcf\">go to the previous page</a>";
   else {
     echo "<a href=\"2.php\">go to the latest page</a>";

what i do if you are on the last page, a link to the first page would
show, and this is not a problem since 0.php can be hardcoded.

my problem, however, is in navigating the pages in decreasing order. is
there any way to look at the current directory and get the token of
only the php pages? i know that i can use the max() function to get the
greatest one listed, but i do not know how to list the files to use the
max() function. any help would be appreciated, and thank you in


Site Timeline