alexjewell
08-19-2010, 11:01 PM
I'm running through images in a directory and outputting them into a table for display. I've attempted, rather wrongly, to echo '</tr><tr>' every 5 images, but the '</tr><tr>' shows up at the END of the echoed images. I know I'm probably going to need a for loop instead, or some combination of for and while. Anyway, here's my current code; any help is appreciated.
$dir_handle = @opendir($path) or die("Unable to open folder");
$num_imgs = 0;
$five_array = array(5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100);
while (false !== ($file = readdir($dir_handle))) {
if($file == ".")
continue;
if($file == "..")
continue;
$each1 = ' <td><img src="../imgs/blog/'.$file.'" alt="http://number12foundation.org/imgs/blog/'.$file.'" /><br /><i>'.$file.'</i><br /><a href="admin.php?page=blogs&blog_page=images&images_page=delete&file='.$file.'">[delete]</a></td>'."\n";
if(!in_array($num_imgs,$five_array)){
echo $each1;
}
else{
echo $each1;
echo "\n".' </tr><tr>'."\n";
}
$num_imgs++;
}
Thanks!
$dir_handle = @opendir($path) or die("Unable to open folder");
$num_imgs = 0;
$five_array = array(5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100);
while (false !== ($file = readdir($dir_handle))) {
if($file == ".")
continue;
if($file == "..")
continue;
$each1 = ' <td><img src="../imgs/blog/'.$file.'" alt="http://number12foundation.org/imgs/blog/'.$file.'" /><br /><i>'.$file.'</i><br /><a href="admin.php?page=blogs&blog_page=images&images_page=delete&file='.$file.'">[delete]</a></td>'."\n";
if(!in_array($num_imgs,$five_array)){
echo $each1;
}
else{
echo $each1;
echo "\n".' </tr><tr>'."\n";
}
$num_imgs++;
}
Thanks!