Show 3 columns per row
Posted: Fri Jan 02, 2004 12:15 pm
i've been programming for the past 12 hours......er......on differnet scripts.....heh....and am stuck on this one. it puzzles me, the tr and td comes out all wierd. I looked around for tutorials on this. bumped into one at spoono too but didn't really help O.o.
anyhow, it'd be great if anyone can point me out. the script works fine, technicly. no parse errors or anything but the display part is just wack. right now it displays 1 image then, 2 images and then 1 image. there's a total of four images. 3 rows right now. should be 2 rows with 3 images on the first and one on the last.
anyone?
-Nay
anyhow, it'd be great if anyone can point me out. the script works fine, technicly. no parse errors or anything but the display part is just wack. right now it displays 1 image then, 2 images and then 1 image. there's a total of four images. 3 rows right now. should be 2 rows with 3 images on the first and one on the last.
Code: Select all
$query = "SELECT image_id, image_url, image_thumb_url, image_caption FROM hnhs_gallery ORDER BY image_id DESC";
$result = $mysql->queryFetch($query);
$content = '';
for($i = 0; $i < count($result); $i++) {
$rows = $result[$i];
$caption = stripslashes($rows['image_caption']);
// get image information
$thumb = $thumbs_dir . $rows['image_thumb_url'];
$big = $big_dir . $rows['image_url'];
$thumbImg = $thumbs_url . $rows['image_thumb_url'];
$bigImg = $big_url . $rows['image_url'];
$thumbInfo = getimagesize($thumb);
$bigInfo = getimagesize($big);
if($thumbInfo[0] == 170 && $thumbInfo[1] == 120) {
$type = 1; // if the image is landscape
} elseif($thumbInfo[0] == 120 && $thumbInfo[1] == 170) {
$type = 2; // if the image is portrait
} else {
$config->FEDieError("Image: {$rows['image_thumb_url']} is not valid");
}
if($i % 3) {
// start a new row
$content .= <<< TR
</tr>
<tr>
TR;
} else {
// start a new column
$content .= <<< TD
<td class="gallery">
<a href="#{$rows['image_id']}" name="{$rows['image_id']}" onclick="window.open('$bigImg', '{$rows['image_id']}', 'width={$bigInfo[0]}, height={$bigInfo[1]}')" title="{$caption}">
<img src="{$thumbImg}" alt="{$caption}" />
</a>
</td>
TD;
}
}
$config->addFEHeader();
print <<< CONTENT
<h1 class="content_title">Gallery</h1>
<div style="width:100%;text-align:center;">
<table cellpadding="5" cellspacing="0" border="0" class="gallery">
$content
</table>
<div style="text-align:right;width:100%">{$links}</div>
</div>
CONTENT;
$config->addFEFooter();-Nay