ok i have a directory on my site where ppl can upload images to, and i also created a page to display all the uploaded pics. my problem is that i want them to display 4 per row. i tired to get this but it doesn't seem to be working. what do i need to edit
Code:
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Directory listing</title>
<style type="text/css" media="screen">
body {
background-color: #FFF;
color: #000;
font-family: Geneva, Arial, sans-serif;
font-size: 100%;
line-height: 140%;
}
img {
border: 0;
height: 100px;
width: 100px;
}
.grey1 { background-color: #CCC; }
.grey2 { background-color: #DDD; }
</style>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="2">
<?php
function usecolor()
{
static $colorvalue;
$trcolor1 = "grey1";
$trcolor2 = "grey2";
if($colorvalue == $trcolor1)
$colorvalue = $trcolor2;
else
$colorvalue = $trcolor1;
return($colorvalue);
}
function test()
{
$default_dir = "./";
if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");
while($file = readdir($dp)) $filenames[] = $file;
closedir($dp);
sort($filenames);
echo "<tr><th>Files</th></tr>\n";
for($i=0; $i < count($filenames); $i++)
{
if($filenames[$i] != 'yo1.php' && !preg_match('/^\./',$filenames[$i]) && !is_dir($filenames[$i]))
// don't show directories, yo1.php and files that start with a dot
$z = $i % 4;
if($z == 0){
echo "<tr><td class=\"" . usecolor() . "\"><a href=\"" . rawurlencode($filenames[$i]) . "\"><img src=\"" . rawurlencode($filenames[$i]) . "\">" . "</td>";
}
else
{
echo "<tr><td class=\"" . usecolor() . "\"><a href=\"" . rawurlencode($filenames[$i]) . "\"><img src=\"" . rawurlencode($filenames[$i]) . "\">" . "</td></tr>\n";
}
}
}
test();
?>
</table>
</body>
</html>
any help would be great, or if you see any bugs in the code please point it out.