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
Share on other sites

Well, as far as I can see $line is undefined and you're not actually reading anything from the file. feof() does not read anything.

 

What are you actually trying to achieve? Chances are, you're making this more complicated than it needs to be.

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.