rendered paste body<? $cerereSQL = "SELECT * FROM `gallerycat` , `gallery` WHERE gallery.cat = gallerycat.id ORDER BY gallery.id ASC "; $rezultat = mysql_query($cerereSQL); $newWidth=0; $indice=0; while($rand = mysql_fetch_assoc($rezultat)) { list($width, $height) = getimagesize($rand['thumb']); //$widthsum[]=$width; $maxHeight[]=$height; if($newWidth>=400) { $newWidth=0; //$newHeight=$indice+max($maxHeight); $indice=$newHeight+max($maxHeight); } else { $newHeight=$indice; $newWidth=$newWidth+$width; } $cssID='id'.$rand['id']; echo $cssID.': top:'.$newHeight.' ,left:'.$newWidth.' WIDTH:<b>'.$width.'</b><br />'; ?>