I would strongly recommend first reading the manual , and then sculpt ...
Here is an example from the manual:
<?php // Обратите внимание, что оператор !== не существовал до версии 4.0.0-RC2 if ($handle = opendir('/path/to/files')) { echo "Дескриптор каталога: $handle\n"; echo "Файлы:\n"; /* Именно этот способ чтения элементов каталога является правильным. */ while (false !== ($file = readdir($handle))) { echo "$file\n"; } /* Этот способ НЕВЕРЕН. */ while ($file = readdir($handle)) { echo "$file\n"; } closedir($handle); } ?>
In your case, you can fix it on:
<?php $filelist = array(); $dir = __DIR__; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (is_file($file)) $filelist[] = $file; } closedir($handle); } foreach ($filelist as $file) { printf("<td>%s</td><td class='action'><a href='#' class='view'>Загрузить</a><a href='#' class='delete'>Удалить</a></td>", $file); } ?>