PHP Newsletter

Join now and receive weekly updates pertianing to the world of PHP.

Polls

What do you think about the new PHPMine Design?
Awesome
Not Bad
Sucks

PHP Gigs By City

PHP Jobs By Topic

Advertisements

I have a PHP script to show the images in a folder, I want to be able to list the differentlyly.?

Asked 2010-02-06 07:34:02 by Tony H

I want to list the file like:
1 2 3
4 5 6
etc.

Here is my code:
$handle = opendir ('./gallery');
while (false !== ($file = readdir($handle))) {
if($file != "." && $file != ".." && $file != basename(__FILE__)) {
echo '<br /><a href="../gallery/'.$file.'"><img src="../gallery/'.$file.'" height=\"20%\" width=\"20%\"/></a><br />';
}
}

Anwered 2010-02-07 20:09:29 by ryan_pendleton2004

Try this:

$handle = opendir ('./gallery');$i=0;
while ($file = readdir($handle)){
if($file != "." && $file != ".." && $file != basename(__FILE__)){ $i++;
echo '<a href="../gallery/'.$file.'"><img src="../gallery/'.$file.'" height="20%" width="20%"/></a>'."\n";
if($i/3==floor($i/3)) echo "<br/>";
}
}

Questions and answers provided by the Yahoo Answers Community.