Howdy 

I have a script that lists files from a directory. What I want to do is
spilt the result up so that files are displayed into a html table that
is 8 colums wide and how ever many rows are needed. 
( my script is below )

Any help would be aprechiated

Cheers 

Peter


Heres my script

<table width="92%"  border="0" align="center" cellpadding="0"
cellspacing="1" >
<?php
/*
* This little example prints a sorted directory 
* listing, with dirs first and files afterwards.
*/

// Open current directory
if($handle = opendir("./images")){
 
 // Loop through all files
 while(false !== ($file = readdir($handle))){
   
   // Ignore hidden files
  if(!preg_match("/^\./", $file)){
     
     // Put dirs in $dirs[] and files in $files[]
     if(is_dir($file)){
      $dirs[] = $file;
     }else{
       $files[] = $file;
    }
   }
 }
 
 // Close directory
closedir($handle);

 // if $dirs[] exists, sort it and print all elements in it.
 if(is_array($dirs)){
   sort($dirs);
  foreach($dirs as $dir){
    # echo "<a href=\"$dir/\">$dir/</a><br />\n";
        echo "";
  }
 }

 // if $files[] exists, sort it and print all elements in it.
 if(is_array($files)){
   sort($files);
   foreach($files as $file){
   $ext = strtolower(end(explode('.', $file)));
   if ($ext == 'jpg' ||$ext == 'jpeg' ||$ext == 'png') {
      echo "<tr><td><a href=\"images/$file\" target=\"_blank\"><img
src=thumb.php?$file></a>\n</td>\n</tr>";
    } else {
        echo "";
   }
  }
 }
}
?>
</td></tr></table>




-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to