Jf88 Posted June 7, 2009 Share Posted June 7, 2009 Hi, I am a complete beginner in PHP. Now I want to make a photo album for my website. I currently have made an index.php with 3 includes to other php pages: toonalbums.php (translation: showalbums.php) This page I use to make an list of all the photo albums that are available in a directory of my choice. The code in this page also needs to generate hyperlinks so I can watch all the photo's inside the specific albums. toonalbuminhoud.php (translation: showalbumcontent.php) This page I use so all the photo's will be visible in thumbnails. The thumbnails need to be hyperlinks so a bigger version of the photo's can be seen. toonfoto.php (translation: showfoto.php) This page I use to show the foto in his original size. The code I currently use is: toonalbums.php <?php $mapnaam = 'albums/'; echo '<ul>'; if ($handle = opendir($mapnaam)) { while (false !== ($albumnaam = readdir($handle))) { echo '<li><a href="?album=' . $_GET['album'] . '"></a></li>'; } closedir($handle); } echo '</ul>'; ?> toonalbuminhoud.php: <?php if(isset($_GET['album'])) { $albumnaam = $_GET['album']; $mapnaam = 'albums/' . $albumnaam; echo '<ul>' ; if ($handle = opendir($albumnaam)) { while (false !== ($fotonaam = readdir($handle))) { echo '<li><a href="?album=' . $_GET['album'] . '$foto=' . $_GET['foto'] . '"> <img class="thumbnail" src="' . $mapnaam . '/' . $fotonaam . '" alt="' . $fotonaam . '"/> </a></li>'; } closedir($handle); } echo '</ul>'; } ?> toonfoto.php: <?php if(isset($_GET['foto'])) { $fotonaam = $_GET['foto']; $mapnaam = 'albums/' . $_GET['album']; echo '<img src="' . $mapnaam . '/' . $fotonaam . '" alt="' . $fotonaam . '"/>'; } ?> the following page is the index with the 3 includes: <body> <div id="albums"> <?php include 'toonalbums.php'; ?> </div> <div id="albuminhoud"> <?php include 'toonalbuminhoud.php'; ?> </div> <div id="foto"> <?php include 'toonfoto.php'; ?> </div> </body> When I execute the index I get the following error: "Notice: Undefined index: album in C:\wamp\www\webprogramming\php2\toonalbums.php on line 9" I don't know exactly what's wrong but I think it has something to do with the variables and the '$_GET['album']' code I use in the echo on the 'toonalbum.php' page. Also the map album exists and there are a couple of maps with photo's inside. I hope someone can help me and explain how I can fix the code, because I think I am pretty close to getting it to work. Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted June 7, 2009 Share Posted June 7, 2009 Does album already exist in the url? I would do something like: if (isset($_GET['album'])) { $album = $_GET['album']; } else { $album = 0; //Whatever default value you want if an album isn't selected } Then change to: echo '<li><a href="?album=' . $album . '"></a></li>'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.