php webcomic navigation script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • l33tp4nt5

    php webcomic navigation script

    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 $p = $_SERVER["SCRIPT_NAM E"]; $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"; $pcf = "$pc.php";

    if (file_exists($n cf)) { echo "<a href=\"$ncf\">g o to the next
    page</a>"; } else { echo "<a href=\"0.php\"> go to the first
    page</a>"; } ?> <br /> <?

    if (file_exists($p cf)) { echo "<a href=\"$pcf\">g o 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
    advance.

    -miguel

Working...