View Single Post
Old 25-08-2010, 18:10   #8
JediMaster
Use The Force
 
JediMaster's Avatar
 
Join Date: Jan 2004
Location: Swansea
Posts: 1,376
JediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these partsJediMaster is just so famous around these parts
Re: PHP Code - Print Filename Under Image

Hi Graham. Now page wont load...

Code:
<?php

foreach($files as $file)
{
$fullname = str_replace('_thumbnail.jpg', '',$file);

$images = "img/"; # Location of small versions
$big    = "img/"; # Location of big versions (assumed to be a subdir of above)
$cols   = 4; # Number of columns to display

if ($handle = opendir($images)) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
           $files[] = $file;
       }
   }
   closedir($handle);
}

$colCtr = 0;

echo '<table width="100%" cellspacing="0" cellpadding="0"><tr>';

foreach($files as $file)
{
  if($colCtr %$cols == 0)
  echo '</tr><tr><td colspan="2"></td></tr><tr>';
  echo '<td align="center"><img src="' . $images . $file . '" /><br> '. $fullname  . '</td>';

  $colCtr++;
}

echo '</table>' . "\r\n";

?>
JediMaster is offline   Reply With Quote