hi there,
i am trying to make photo gallery in php.
gallery reads directories and display directories as links. left cell of table.
if you click on link, it opens the folder and displays small thumbs of pictures from that folder.
at the moments script works just fine.
my problem is display of thumbs ( in the right table cell ), its displaying them in one row. how can i make them display in three per line?
my code :
<?php
// config variable
$col = 3; // number of column
$maxrow = 1; // max row for table
$picdir = ".";
$dpic = opendir($picdir);
while($folder = readdir($dpic))
{
if($folder!="." && $folder!=".." && is_dir($folder))
{
if(substr($folder,-3)!="jpg")
$seldir[] = $folder;
}
}
natsort($seldir);
foreach($seldir as $value)
{
$alldir[] = "$value";
}
?>
<table width="500" border="0" cellspacing="0" cellpadding="5">
<tr><td width="283" valign="top"><div style="height:100%">
<div>Odaberite Kategoriju:</div>
<?
foreach($alldir as $key)
{
$dirname = strtoupper(str_replace("_"," ",$key));
print "<li><a href=\"dir.php?dir=$key\" class=\"text\">$dirname »</a></li> ";
}
print "<td width=\"250\" align=\"center\"><br />";
if(isset($dir))
{
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes
$dimg = opendir($dir);
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$a_img[] = $imgfile;
sort($a_img);
reset ($a_img);
}
}
$totimg = count($a_img); // total image number
for($x=0; $x < $totimg; $x++)
{
$halfwidth = ceil($size[0]/2);
$halfheight = ceil($size[1]/2);
// echo 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />';
$imagehw = getimagesize("$picdir/$dir/$a_img[$x]");
$height = 100;
$width = (int)(($imagehw[0]*100)/$imagehw[1]);
/////////
$ctime = filectime("$picdir/$dir/$a_img[$x]");
if("$dir/$a_img[$x]" !="")
print "<a href=\"javascript:PopupPic('$picdir/$dir/$a_img[$x]')\">
<img src=\"$picdir/$dir/$a_img[$x]\" height=\"$height\" width=\"$width\" border=\"0\" alt=\"$picdir/$dir/$a_img[$x]\" />
</a><br />\n";
}
}
?>
Thank you,
Rutin