Page 1 of 1

Image order help!

Posted: Wed Dec 01, 2004 12:04 am
by stormybaka

Code: Select all

<?php
$cols = 6; 
$table_bg_color = "#000000"; 
$table_border_color = "#339933";  
$table_border = "0";  
$table_width = "60%";  


$i =1;
$files = array ();
$myDirectory = opendir("thumbs");
echo "<table width='$table_width' bgcolor = '$table_bg_color' border ='$table_border'bordercolor ='$table_border_color'  cellpadding='5' cellspacing='0'><tr>";
while ($file = readdir($myDirectory)) {

if (($file != ".") && ($file != "..") && ($file != "index.php") && !(is_dir("$file")) )
{
$files[] = $file;
if (is_int($i / $cols)) {
list($width, $height) = getimagesize("$file");
echo "<td align='center'>";
?>
<a href="#" onClick="MyWindow=window.open('noodles.php?file=<?php echo $file;?>','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=<?php echo "$width";?>,height=<?php echo "$height";?>,left=20,top=20'); return false;">
<?
echo "<img src='thumbs/$file' border='0'></a>";
echo "</td></tr><tr>";
}
else
{
list($width, $height, $type, $attr) = getimagesize("$file");
echo "<td align='center'>";
?>
<a href="#" onClick="MyWindow=window.open('noodles.php?file=<?php echo $file;?>','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=<?php echo "$width";?>,height=<?php echo "$height";?>,left=20,top=20'); return false;">
<?
echo "<img src='thumbs/$file' border='0'></a>";
echo "</td>";
}
$i++;
}}
echo "</tr></table>";
closedir($myDirectory);
?>
Anyway of making this show by alphabetical order?

Posted: Wed Dec 01, 2004 12:52 am
by rehfeld
read all the files into an array, then use sort()

then loop through them and echo out the names and html etc...