Hi, I have 13 folders with a few thousand images each, now the client wants me to export the "gallerys" to another server that does not run php....so he wants plain .htm files.
Below is how far I have come to "porting" this... the idea being: generate .html files then simply copy the images folders to the clients other server and dump the html files there and he has a gallery ready to go..this is how i thought of it: 1: read number of images from a directory (done) 2: After reading, divide the number by 100 (eg: 1348 images equals 14 pages...last page only 48 pics) (done) 3: Dynamically create the .html files via a "fopen" (done) 4: put 100 <img> tags to call 100 images per page (confused here) The images are numbered sequentially but dont start from 0 or 1, they start from something like 00047.jpg or 0024.jpg etc I think I will need a foreach (and tried a foreach...but didnt work) but am confused...ANY help appreciated. ************** Start code **************** <?php function directory($dir,$filters){ $handle=opendir($dir); $files=array(); if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != "all"){ $filters=explode(",",$filters); while (($file = readdir($handle))!==false) { for ($f=0;$f<sizeof($filters);$f++): $system=explode(".",$file); if ($system[1] == $filters[$f]){$files[] = $file;} endfor; } } closedir($handle); return $files; } $pics=directory("pics","jpg,JPG,JPEG,jpeg,png,PNG"); $total_pics=count($pics); $pages = ceil($total_pics / 100); // using ceil so 12.23 translates to 13 $content="Mag"; /* foreach ($pics as $p) // $p is the name of the file {$content.=$content."<img src='thumbs/tn_".$p."'>";} */ for($i=0; $i<$pages;$i++) { if($i==0){$j="";}else{$j=$i;} $index="index".$j; if(!$handle = fopen($index.".html", "w")) {echo "Cannot open file ($filename)";exit;} if(fwrite($handle, $content) === FALSE) {echo "Cannot write to file $filename)";exit;} fclose($handle); } echo "The end"; ?> ************** End code **************** The above code is working so far as to: 1.read from the dir 2.create the required number of pages while making sure the first page is index.html 3. Writing some content in..in this case just: "Mag" Thanks, Mag ===== ------ - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php