How are you guys? I'm trying to display some images with text under them and for some reason only the first letter of text appears and the rest of the line is truncated? Does anyone know what the problem is? Also the image file name appears on the page. And finally does anyone know how to modify my code to allow for multiple pages of images after the first page is full?
Here is the code from the text file and the php file.
PHP file:
<?php
$images = "image_gallery/"; # Location of small versions
$big = "big/"; # Location of big versions (assumed to be a subdir of above)
$cols = 2; # Number of columns to display
$text = "text.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 src="' . $images . $file . '" /></a><br />' . $description[$file][0] . '</td>';
$colCtr++;
}
echo '</table>' . "\r\n";
echo $allfiles;
?>
and now for the text file text.txt
camronxxl.jpg,Balloon Fiesta!
anna_nicole.jpg,Some Anna Nicole Text
dontcare.jpg,My little ghoulish helpers
beyonce.jpg,Our Halloween Pumpkin
Here is the code from the text file and the php file.
PHP file:
<?php
$images = "image_gallery/"; # Location of small versions
$big = "big/"; # Location of big versions (assumed to be a subdir of above)
$cols = 2; # Number of columns to display
$text = "text.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 src="' . $images . $file . '" /></a><br />' . $description[$file][0] . '</td>';
$colCtr++;
}
echo '</table>' . "\r\n";
echo $allfiles;
?>
and now for the text file text.txt
camronxxl.jpg,Balloon Fiesta!
anna_nicole.jpg,Some Anna Nicole Text
dontcare.jpg,My little ghoulish helpers
beyonce.jpg,Our Halloween Pumpkin