Jump to content

Picture Gallery Script help


speaker219

Recommended Posts

How would i make a script that would get all of the pictures in a folder, and display one, but include a "Next Picture >>" and "Previous Picture <<" link. so when you first open the script you get 1 picture, and a link to go to the next/previous one.

i wrote a script that gets all of the images in a folder and displays them, but i don't want it to show all of them at once.

<?php
$ignore = array('.','..','index.php');
$handle = opendir('.');
while ($file = readdir($handle)) {
if (!in_array($file, $ignore)) {
echo '<img src="'.$file.'"><br><hr>';
}
}
closedir($handle);
?>

 

Any help would be appreciated

Link to comment
Share on other sites

$path = "/home/path/to/your/folder";

$handle = @opendir($path) or die("Unable to open $path");

echo "<table border=0 cellspacing=3 cellpadding=3>\n";
$x=1;
echo "<tr>\n";
while($file = readdir($handle)){
echo "<td><img src=\"$file\"></td>\n";

  if($x == 5){
  echo "</tr><tr>\n";
  $x=0;
  }
$x++;
}
echo "</tr>\n";
echo "</table>\n";

closedir($handle);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.