Nachdenken, dann programmieren!
In einer Schleife macht die einfache Zuweisung ($i = 1) keinen Sinn, weil jedes mal der Wert überschrieben wird.
$filename + 1? Türrahmen * pi?
PHP-Code:
<?php
$photos = glob("bilder/januar09/*.*");
$currPhotoId = isset($_GET["photo"]) ? $_GET["photo"] : 0;
if (!isset($photos[$currPhotoId])) {
$currPhotoId = 0;
}
$currentPhoto = $photos[$currPhotoId];
$prevPhotoId = max(0, $currPhotoId - 1);
$nextPhotoId = min(count($photos) - 1, $currPhotoId + 1);
?>
<img id="photo" src="<?php echo $currentPhoto ?>" />
<a href="album.php?photo=<?php echo $prevPhotoId ?>">zurück</a>
<a href="album.php?photo=<?php echo $nextPhotoId ?>">weiter</a>
Das ganze ohne Seitenwechsel wäre Schritt 2.