So I have a photo album online, and I'm having some trouble just with some formatting stuff. If you go to http://oxidephoto.ca/?level=album&id=17 you'll see that the number of pictures is not divisible by 4, so there's some empty space. I'd like to fill those with empty <div>'s, so I've devised the following:
PHP Code:
<?php
if (($numpics%4)!=0) { for ($counter = 0; $counter == ($numpics%4); $counter += 1) { echo '<div class="collection"> </div>'; } }
?>
I initialize the $numpics variable before a big while loop, it's incremented in the loop, and then I use that above code to attempt to generate the empty <div>'s. The page loads, so I know the code is valid at least, but it's not working as I expect. The whole page's code is below. Any ideas? Thanks!
Code:
<div id="collections">
<?php while(plogger_has_pictures()) : ?>
<?php
$host="localhost";
$username="usr";
$password="pass";
$database="_db";
$siteurl="http://www.oxidephoto.ca";
//Database Connection
$connection = mysql_connect($host, $username, $password);
$db = mysql_select_db($database);
$q = "SELECT * FROM `plogger_pictures` WHERE DATE_SUB(CURDATE(),INTERVAL 14 DAY) <= date_submitted";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
}
?>
<?php plogger_load_picture();
// set variables for the album
$capt = plogger_get_picture_caption();
// find thumbnail width
$thumb_info = plogger_get_thumbnail_info();
$thumb_width = $thumb_info[0]; // The width of the image. It is integer data type.
$thumb_height = $thumb_info[1]; // The height of the image. It is an integer data type.
$numpics++;
?>
<div class="collection">
<a href="<?php echo plogger_get_picture_url(); ?>"><img id="thumb-<?php echo plogger_get_picture_id(); ?>" class="photos" src="<?php echo plogger_get_picture_thumb(); ?>" width="<?php echo $thumb_width; ?>px" height="<?php echo $thumb_height; ?>px" title="<?php echo $capt; ?>" alt="<?php echo $capt; ?>" /></a>
<div class="checkbox"><?php echo plogger_download_checkbox(plogger_get_picture_id()); ?></div>
<p style="width:<?php echo $thumb_width; ?>px;"><?php if ($id == plogger_get_picture_id()) {echo "NEW!<br />";} ?><?php echo $capt; ?></p>
</div>
<?php
if (($numpics%4)!=0) {
for ($counter = 0; $counter == ($numpics%4); $counter += 1) {
echo '<div class="collection"> </div>';
}
}
?>
<?php endwhile; ?>
</div>
<?php else : ?>
<div id="no-pictures-msg">There are no pictures in this album.</div>
<?php endif; ?>
</div>
__________________
This is my edited bleeding signature.
Last edited by chrishirst : 12-15-2007 at 10:47 AM.
|