the latest
October 20, 2008 New Backup Script has been launched. Some house keeping has been done around the site and we have a few new items to be added soon.

the greatest

» Backup Script
» Contact Script
» PHP Includes
» Image Gallery

Image List

Description

This tutorial will show you how to display all of the images in a directory.

Tutorial

Not really the prettiest way to display your images but its very easy and has room for customization.

Here is a an easy example:

<?

//define the path to your images
$path = "/home/yourdomain/public/images";

//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");

//show a title of the page and start a table
echo "Listing of $path<br/><table><tr><td>";

//running the while loop
while ($file = readdir($dir_handle))
{

//Stops the "directories" from being listed
if($file!="." && $file!="..")

//Displays the images, this may vary depending on where you put your php file.
//For example you may need to put something like:
//echo "<img src='/homedir/vacationpics/images/$file'>";
echo "<img src='/images/$file'>";
}

//close the table
echo "</td></tr></table>";

//closing the directory
closedir($dir_handle);

?>


This is best used on directories that only have images in them, otherwise it will try to display the non-images files as images which looks silly.


Home : Services : Scripts : Tutorials : Hosting : Contact