yeah, so my friend is making a web comic type thing and I'm making an archive type thing for him. How it's supposed to work is that it displays the latest comic (this part works) and then allow the user to browse through all the comics using link type stuff (this is what doesn't work). so if someone could tell me what I'm doing wrong, I'd appreciate it.
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<table>
<tr>
<td colspan=2>
<?php
$self = $_SERVER['PHP_SELF'];
$base="/Images/";
$num=CountFiles("./Images", "GIF");
if(!(isSet($dispnum)))
{$dispnum=sprintf("%03s",$num);}
$dispnext=sprintf("%03s",$dispnum+1);
$dispprev=sprintf("%03s",$dispnum-1);
function CountFiles($dir, $type)
{
if(!($dh =@opendir("$dir")))
return false; // directory does not exist
// read the directory contents searching for "type" files
// and count how many are found:
$files = 0;
while ( ! ( ($fn = readdir($dh)) === false ) )
{
$f = strrev($fn);
$ext = substr($f, 0, strpos($f,"."));
$f_ext = strrev($ext);
if(( strcasecmp($f_ext, $type) == 0 )) $files++;
}
closedir($dh);
return $files;
}
?>
<img src="<?php print("$base$dispnum.GIF"); ?>">
</td>
</tr>
<tr>
<td>
<?php
if($dispnum>"001")
{
?>
<a href="<?php echo("?dispnum=$dispprev"); ?>">Previous</a>
<?php
}
else
{
print("Previous");
}
?>
</td>
<td>
<div align=right>
<?php
if($dispnum==$num)
{
print("Next");
}
else
{
?>
<a href="<?php echo("$self?dispnum=$dispnext"); ?>">Next</a>
<?php
}
?>
</div>
</td>
</tr>
</table>
</body>
</html>