talisien 0 Newbie Poster
<?

// This is the directory to list files for.
$theDirectory            = "upload"; // without the /
// Do you want to show directories? change to false to hide directories.
$listDirectories    = false;
if(is_dir($theDirectory))
{

echo "<table>";
echo "<tr>";

$dir = opendir($theDirectory);
$counter = 1;
while(false !== ($file = readdir($dir)) )
{
$type    = filetype($theDirectory ."/". $file);
if($listDirectories || $type != "dir")
{
	$ext = pathinfo($file);
       // checks if the file is an image
	if($ext['extension'] == 'jpg' or $ext['extension'] == 'gif' or $ext['extension'] == 'png' ){
			

echo "<td><img src='$theDirectory/$file' height='75' width='75' /><br />".$counter." - ". $file."</td>";
$counter++; 
}
        // checks if the file other than an image 
	if($ext['extension'] == 'zip' or $ext['extension'] == 'rar' or $ext['extension'] == 'doc' or $ext['extension'] == 'txt') {
echo "<td valign='bottom'>is not an image file<br />".$counter." - " .$file."</td>";

$counter++;

}

}
}

closedir($dir);
echo "</tr>";

echo "</table>";
}
else
{
	
echo $theDirectory . " is not a directory";
}

	  
?>

Script shows the content of an directory and makes a difference between image files and other files than images and displays it as one row.

Now i like so see that the content of the directory is split into columns and row instead of one single row.

like this:

file1 file2 file3 file4 file5 file6
file7 file8 file9 file10 file11 file12
etc.

I tried for loops but that's resulting into multiple rows with this as a result.

file1 file2 file3 file4 file5 file6
file1 file2 file3 file4 file5 file6
file1 file2 file3 file4 file5 file6
etc.

If there's an easier way to do this, then please let me know.

script is taken from the net and is little modified by me. the original show also the file type and the size of the file, but i didn't need those features.

Leon