<table width="342" border="0" cellspacing="0" cellpadding="0">
<tr>
<?php
/* VARIABLES:
$num_pics = number of pictures in teh folder
$x = a counter
$file_base = filename without the 3-digit number extension */
$num_pics = 71;
$file_base = "images/Whitby/Hockey/Atom AAA/2003-2004/thumbnails/atomaaa";
$x = 1;
if ($num_pics >= $x) {
if ($x % 4 = 0) {
echo "<td width=75><img src='" . $file_base . leading_zero($x, 3, 0) . ".jpg' alt='Thumbnails' border=0></td>" . "<td width=15> </td></tr><tr>"; //print with new row
$x++; //increase pic #
}
else {
echo "<td width=75><img src='" . $file_base . leading_zero($x, 3, 0) . ".jpg' alt='Thumbnails' border=0></td>" . "<td width=15> </td>"; //print without new row
$x++;
}
else {
$x--; //x is now one greater than the number of files, so bump it down
$y = 4 - ($x % 4); //find the number of empty rows that need filling
</td>
</tr>
</table>
<?php
function leading_zero( $aNumber, $intPart, $floatPart=NULL, $dec_point=NULL, $thousands_sep=NULL) { //Note: The $thousands_sep has no real function because it will be "disturbed" by plain leading zeros -> the main goal of the function
$formattedNumber = $aNumber;
if (!is_null($floatPart)) { //without 3rd parameters the "float part" of the float shouldn't be touched
$formattedNumber = number_format($formattedNumber, $floatPart, $dec_point, $thousands_sep);
}
//if ($intPart > floor(log10($formattedNumber)))
$formattedNumber = str_repeat("0",($intPart + -1 - floor(log10($formattedNumber)))).$formattedNumber;
return $formattedNumber;
}
?>
You should have two equals signs there since you're comparing/evaluating rather than assigning.
if ($x % 4 == 0)
I'm not sure if that's why you're getting errors though. But I also noticed you have two else statements in a row. I think you need to change the last one to elseif or if.
You're also missing some quotes and the semi-colon at the top where you declared your variables.
Yes, you can nest statements like that no problem.
I think I misread your code initially because it was missing a closing bracket for one of your 'if' statements, it appeared as if there were two else statements on the same if. I see what you're trying to do now.
<table width="342" border="0" cellspacing="0" cellpadding="0">
<tr>
<?php
/* VARIABLES:
$num_pics = number of pictures in teh folder
$x = a counter
$file_base = filename without the 3-digit number extension */
$num_pics = 71;
$file_base = "images/Whitby/Hockey/Atom AAA/2003-2004/thumbnails/atomaaa";
$x = 1;
if ($num_pics >= $x) {
if ($x%4 == 0) {
echo "<td width=75><img src=\"".$file_base.leading_zero($x, 3, 0).".jpg\" alt=\"Thumbnails\" border=0></td><td width=15> </td></tr><tr>"; //print with new row
$x++; //increase pic #
}
else {
echo "<td width=75><img src=\"".$file_base.leading_zero($x, 3, 0).".jpg\" alt=\"Thumbnails\" border=0></td><td width=15> </td>";
//print without new row
$x++;
}
}
else {
$x--; //x is now one greater than the number of files, so bump it down
$y = 4 - ($x % 4); //find the number of empty rows that need filling
while ($y > 0 ) { echo "<td width=75> </td><td width=15> </td>"; $y--; }
}
?>
</tr>
</table>
</td>
</tr>
</table>
<?php
function leading_zero( $aNumber, $intPart, $floatPart=NULL, $dec_point=NULL, $thousands_sep=NULL) { //Note: The $thousands_sep has no real function because it will be "disturbed" by plain leading zeros -> the main goal of the function
$formattedNumber = $aNumber;
if (!is_null($floatPart)) { //without 3rd parameters the "float part" of the float shouldn't be touched
$formattedNumber = number_format($formattedNumber, $floatPart, $dec_point, $thousands_sep);
}
//if ($intPart > floor(log10($formattedNumber)))
$formattedNumber = str_repeat("0",($intPart + -1 - floor(log10($formattedNumber)))).$formattedNumber;
return $formattedNumber;
}
?>
Oops! LOL I just took a quick look at it and I was looking where you have the multi line comments up at the top. That's why I thought you were missing some quotes and such.
And I also thought there was only one if statement which is why I was confused with both your else statements in a row like that. But I see them now.
It's always a challenge debugging other programmer's scripts until you learn their programming styles. Programming languages like Perl and PHP allow multiple ways to accomplish the same task.