Directories read to table
Posted: Thu Mar 08, 2007 11:14 am
Hi, im trying to write a page that looks in 1 sub directory for a list of games, and then a seperate sub directory for thumnail images for them. I have then tried to get it to produce a table with the thum in one column and the name and hyperlink to load the game in the other, then loop over the array. When i run the page none of the arrays are echo'd, and im not sure how to remove the . and .. from the returned array.
There are mutiple errors with this but it is only the second page ive made, any help would be appreciated.
Code: Select all
<?php
if ($handle = opendir('/var/www/html/games/flash/')) {
while (false !== ($games = readdir($handle))) {
usort($games, 'strnatcmp');
}
closedir($handle);
}
if ($handle = opendir('/var/www/html/games/thum/')) {
while (false !== ($thums = readdir($handle))) {
usort($thums, 'strnatcmp');
$thums=$thum;
}
closedir($handle);
}
echo "<table summary=\"Games\" width=\"720\" align=\"center\"border=\"0\">\n";
$rows = ceil( count( $games) );
$counter = 0;
for( $i = 0; $i <$games; $i++ )
{
echo "<tr>";
echo "<td><a href=\"http://grahamserver.hopto.org/games/game.php?id=$games\"><img src=\"./thum/thum$\" width=\"392\" height=\"208\" border=\"0\" alt=\"0\"/></a></td>\n";
echo "<td> '$games'</td></tr>\n";
}
echo "</table>\n";
?>