Jump to content

Sending a glob of images into columned table


leszer

Recommended Posts

Hi and thanks for the help ahead of time.  I've changed this code about 25 times and I'm sure I'm missing something simple but all I get are issues and I'm not sure if it's me or Yahoo hosting.

 

This is my code, all I'm doing is pulling images from a directory with a glob and trying to output them into a table with 2 columns that grows if necessary.  Maybe someone has a better way altogether, I'm happily open to learning new ways to do things.  I think I'm simply too close to the project at this point.  Thanks again.

 

<?php
$folder = 'images/';
$filetype = '*.*';
$files = glob($folder.$filetype);
$count = 0;
$count = count($files);
$cols  = 2;


echo '<table width="100%" cellspacing="3"><tr>';
foreach($files as $file)
{
    if($count %$cols == 0)
echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
echo '<td align="center"><img src="' . $file '" /></a></td>';
$count++;


}
echo '</table>' . "\r\n";
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.