Jump to content

image gallery


Gazz1982

Recommended Posts

I have this code:

 

<? include("header.php") ?>
<? include("side_left.php")?>

<div class="middle">
  <h1>Gallery</h1>
  


<?php /*

$images = "uploads/"; # Location of small versions
$big    = "images/"; # Location of big versions (assumed to be a subdir of above)
$cols   = 2; # 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 height="50px" cellspacing="3"><tr>';

foreach($files as $file)
{
  if($colCtr %$cols == 0)
    echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
  echo '<a href="' . $images . $big . $file . '"><img width="300px" src="' . $images . $file . '" /></a><br /><br />';
  $colCtr++;
}

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

------------------- 

$images = "uploads/"; # Location of small versions
$big    = "thumbs/"; # Location of big versions (assumed to be a subdir of above)
$cols   = 2; # 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="3"><tr>';

foreach($files as $file)
{
  if($colCtr %$cols == 0)
    echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
  echo '<td align="center"><a href="' . $images . $big . $file . '"><img width="200px" src="' . $images . $file . '" /></a></td>';
  $colCtr++;
}

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

*/

$images = "uploads/"; # Location of small versions
$big    = "thumbs/"; # Location of big versions (assumed to be a subdir of above)
$cols   = 2; # Number of columns to display
$text   = "des.txt";

$fh=fopen($text, "r");

while(!feof($fh))
{
  $temp = explode(",", $line);
  $description[$temp[0]] = $temp[1];
  $line=fgets($fh);
  unset($temp);
}

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="3"><tr>';

foreach($files as $file)
{
  if($colCtr %$cols == 0)
    echo '</tr><tr><td colspan="' . $cols . '"><hr /></td></tr><tr>';
  $allfiles .= $file . ',<br />';
  echo '<td align="center"><a href="' . $images . $big . $file . '"><img width="300px" src="' . $images . $file . '" /></a><br />' . $description[$file][0] . '</td>';
  $colCtr++;
}

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


?> 
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<? include("side_right.php")?>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<? include("footer.php")?>

 

it links to this text file for the descriptions des.txt

file_name,text to display

scan0006.jpg,Pic1
scan0005.jpg,Pic2
scan0003.jpg,Pic3
scan0009.jpg,Pic4
scan0002.jpg,
scan0008.jpg,
scan0001.jpg,
scan0004.jpg,
scan0007.jpg,

 

This only displays the 1st letter how do I fix it?

Link to comment
https://forums.phpfreaks.com/topic/109170-image-gallery/
Share on other sites

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.