djkirstyjay Posted February 13, 2008 Share Posted February 13, 2008 Hi folks! I'm new to this forum. I have been meaning to for a while, but am finally taking the plunge and trying to learn some meaningful PHP to help with a gallery I want to develop in order to display my kid's pics to my family. I am a complete novice at this. I can understand HTML XHTML and CSS, but have only dabbled in PHP in the past in the form or the odd include. I have kindly been given a bit of code from a friend of mine that will list pics within a foder, which will in tun link to the thumb of the pic as follows (I have a vague idea what it does, but that's about it) : <? class ListPics { function SetVars($folder) { $this->folder=$folder; } function listFiles() { $dir = opendir($this->folder); $i=0; $imageNames=array(); while ($file = readdir($dir)) { $imageNames[$i][0]=$file; $imageNames[$i][1]=strtolower($file); $i++; } sort($imageNames); ?> <table border=0 cellspacing=4 cellpadding="0"> <tr> <? $k=4; for ($j=0;$j<$i;$j++) { if ($j>1) { if ($k==4) {echo "<tr>"; $k=0;} $image='<img src="'.$this->folder.'/'.$imageNames[$j][0].'" border="0" alt="'.$imageNames[$j][0].'">'; $sp = strpos($image,"TH"); if($sp > 0) { //$bigpic = $imageNames[$j][0]; $bigpic = eregi_replace("TH","",$imageNames[$j][0]); echo ' <td valign="center" align=center><a href='.$this->folder.'/'.$bigpic.' target="_blank">'.$image.'</a></td> '; $k++; } if ($k==4) {echo "</tr>"; $k=0;}; } } ?> </tr> </table> <p> <a href="#top">back to top</a> </p> <? } } ?> That is fine for having the pics in a folder displayed in thumbnail form, which is then clickable to the larger pic, however what I also want to do is have a page where a list of the actual folders appears, but rather than displaying the folderlist, a thumb which will be named 'main.jpg' will display, which is then clickable to the page that displays the pics as the code above does. Am I making sense? Can anyone give me a few pointers? I have been searching the web and am just getting more confused, so some laymans terms might be needed! Any help would be greatly appreciated! Kirsty EDIT : Forgot to say, my phpinfo says my server is running PHP Version 4.2.2 Link to comment https://forums.phpfreaks.com/topic/90987-getting-folder-list-to-automatically-display-with-an-image-from-each-folder/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.