Jump to content

Sending a glob of images into columned table


Go to solution Solved by requinix,

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";
?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.