Simplest Image Gallery with PHP
Posted: Tue May 10, 2011 12:43 pm
Ok, I gave up following the Automatic Image Gallery tutorial for the moment. I will go with a rather simpler version of image gallery now. I have two issues though.
Firstly, please go to http://nailyener.com/otel/resimler.php and you will see how it looks now. You will notice that the images are not sorted alphabetically, this is problem 1, I want to sort images alphabetically.
Next, when you click on an image, another page opens with a larger version of the image and "Back" "Next" buttons. I have no idea how to code "Back" and "Next" buttons, this is problem 2.
Below, you will see the files:
resimler.php
Firstly, please go to http://nailyener.com/otel/resimler.php and you will see how it looks now. You will notice that the images are not sorted alphabetically, this is problem 1, I want to sort images alphabetically.
Next, when you click on an image, another page opens with a larger version of the image and "Back" "Next" buttons. I have no idea how to code "Back" and "Next" buttons, this is problem 2.
Below, you will see the files:
resimler.php
<?php include 'includes/header.php'; ?> <div id="title"><a href="tr.php">Ana Sayfa</a> » Resimler</div> <?php $dir = "gallery/"; if ($opendir = opendir($dir)) { while (($file = readdir($opendir)) !== FALSE) { if ($file!="."&&$file!="..") echo "<div class='images'><a href='tr-img.php?img=$file'><img src='$dir$file' width='100' height='100' alt='$file' /></a></div>"; } } ?> <?php include 'includes/footer.php'; ?>tr-img.php
<?php include 'includes/header.php'; ?> <div id="title"><a href="tr.php">Ana Sayfa</a> » <a href="resimler.php">Resimler</a></div> <div id="content"> <div class="imgpage"> <?php $file = $_GET[img]; $dir = "gallery/"; echo "<img src='$dir$file' width='200' height='200' alt='$file' />"; ?> </div> <div class="imgnavi"><a href=''>Back</a> | <a href=''>Next</a></span></div> </div> <?php include 'includes/footer.php'; ?>