470,862 Members | 1,769 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

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_NAME"]; $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($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


Jan 4 '06 #1
1 2821
The function you need is glob().

Jan 4 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Salagir | last post: by
2 posts views Thread by Captain BirdsEye | last post: by
2 posts views Thread by Marc Castrechini | last post: by
28 posts views Thread by laredotornado | last post: by
10 posts views Thread by EA | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.