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
https://forums.phpfreaks.com/topic/60914-picture-gallery-script-help/
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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.