I'm trying to write a pretty quick and (inherently) dirty image gallery script for my site. I've lost a lot of the PHP zing that I probably never had, but I'm pretty sure this script should work, but it doesn't. Does someone mind telling me why? Also, the $dir directory is full of images, $th with thumbnails of them, and info.txt has descriptions of each picture per line of the text file and I'm not really interested in optimization right now, just getting it to work. Thanks guys. [code] //set directories $dir = "./images/gallery/$set"; $th = "./images/gallery/thumbnails/$set"; //description call $info = @fopen("./images/gallery/$set/info.txt", "r"); if ($info) { while (!feof($info)) { $descs = fgets($info); $desc[] = $descs; } fclose($info); } //reads files $fd = @opendir($dir); while (($part = @readdir($fd)) == true) { clearstatcache(); if ($part != "." && $part != "..") { $gal[] = $part; } } //set while variables $icount = "0"; $counts = "0"; $spot = "0"; $result = count($gal); if ($result > 3) { $row = ($result / 3); $sec = ($result % $row); $thi = ($result / 3) - ($result % 3); if ($sec != "0") { $row = $thi++; } $col = ($result / $thi); } else { $row = "1"; $col = $result; } //start table print "<table width=\"575px\">\n"; //start row count loop while ($spot < $row) { echo "<tr width=\"575px\">\n"; //start column count loop while ($icounts < $col) { echo "<td width=\"33%\"><center><a href=\"$dir/{$gal[$icount]}\"><img src=\"$th/{$gal[$icount]}\" border=\"0\"></a><br>{$desc[$icount]}</center></td>\n"; $counts = $counts++; $icount = $icount++; //end column count loop } echo "</tr>\n"; $counts = "0"; $spot = $spot++; //end row count loop } //end table echo "</table>"; [/code]