PHP IF help

monktus

Registered
Hi guys

I could do with some help editing some PHP. I'm using Dave Tufts' excellent PHP photo gallery script and I'd like to change the number of columns in a dynamically created table. The page in question can be found here:

http://weegiedirtyweekenders.org.uk/photos.html (link to popup window at /photos/gowanbank.php)

...and this is the code (sorry about the formatting, can't the damn CODE tag to work):

/* --------------------------------------------------------------- *
* DISPLAY - thumnail GIFs
* --------------------------------------------------------------- */
if ($use_gifs) {
?>
<table cellpadding="10" cellspacing="0" border="0" align="center">
<tr>
<?php
$i = 0;
if (!((int) $columns)) {
$columns = 4;
}
foreach($image as $v) {
($i % $columns) ? $row = FALSE : $row = TRUE;

if ($i && $row) {
print("\t</tr>\n");
print("\t<tr>\n");
}
print("\t\t<td valign=\"middle\" align=\"center\"><a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $v . "\"><img src=\"" . $v . ".gif\" alt=\"\" border=\"1\"></a></td>\n");
$i++;
}
?>
</tr>
</table>
<?php
}

I'd thought that the line where the $columns variable = 4 might be the maximum number of columns but my page displays 5 (and I'd like 4 to be the maximum). My PHP (and logic) isn't that great so I'd appreciate any suggestions.

Cheers,
Craig
 
yes. i think you'll find it's to do with the 0 + 3 = 4, because 0 is a number. so you actually have 0, 1, 2, 3.
 
Back
Top