Gazz1982 Posted June 7, 2008 Share Posted June 7, 2008 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 More sharing options...
Gazz1982 Posted June 7, 2008 Author Share Posted June 7, 2008 any ideas why this happends? im stuck! Link to comment https://forums.phpfreaks.com/topic/109170-image-gallery/#findComment-560058 Share on other sites More sharing options...
GingerRobot Posted June 7, 2008 Share Posted June 7, 2008 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 https://forums.phpfreaks.com/topic/109170-image-gallery/#findComment-560059 Share on other sites More sharing options...
Gazz1982 Posted June 7, 2008 Author Share Posted June 7, 2008 it displays the image from a folder but the $text part links a caption - currently it only displays the first letter for some reason Link to comment https://forums.phpfreaks.com/topic/109170-image-gallery/#findComment-560061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.