Hi guys. Just a quick PHP question. I have a script running that gets the files from a directory. There is then a switch function that decides what to do with the file, ie... if it is a PNG... DO THIS.. if it is a docx... DO THIS.. etc.
And i want each file to be in a different cell on the table. The table can be longer wider than 5 columns (however it can be as high as it wants). I currently have this bit working... but instead of one item in each cell... it is displaying every item in each cell. Any ideas Chaps? Here is my code
Many thanks in advance if you could possibly help..
echo "<table><tr>";
$count = count(glob("../../shared/files/*.*", GLOB_BRACE));
for($i=1; $i <= $count; $i++)
{
///
echo "<td>";
///
if ($handle = opendir('../../shared/files/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$break = pathinfo($file);
$b = $break['extension'];
switch (@$break[extension]) {
case 'bmp' :
echo 'A BMP<br>';
break;
case 'png' :
echo 'A PNG<br>';
break;
case 'doc' :
case 'docx' :
echo 'A DOC OR DOCX<br>';
break;
default:
echo 'FILE NOT RECOGNISED<br>';
}
}
}
closedir($handle);
}
///
echo "</td>";
///
if($i % 3 == 0)
echo "</tr><tr>";
}
echo "</tr></table>";
?>