Hmmm... I'm pretty sure 1%3 is equal to 1. 

I'm suspecting you might be incrementing $photocount too early -- that is,
before the if (($photocount % 3) == 2)  statement. That would certainly
explain the weirdness you're seeing.

--Todd


> -----Original Message-----
> From: Johnson, Kirk [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 26, 2001 1:57 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Table looking odd as a result of while loop?
> 
> 
> Is it because 1 % 3 is 0 with a remainder of 2? Looks like 
> the code is doing
> just what it is written to do. The "if" evaluates to true on 
> the second
> picture.
> 
> Kirk
> 
> -----Original Message-----
> From: James, Yz [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 26, 2001 2:55 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Table looking odd as a result of while loop?
> 
> 
> Hi all,  This is probably something dumb I'm missing, but I 
> am using the
> following code:
> 
> echo "<table border=\"0\">\n";
> 
> echo "<tr>\n";
> $photocount = 0;
> 
> while($row = mysql_fetch_array($result)) {
>      $smallpic = $row['smallpic'];
> 
>  if (($photocount % 3) == 2) {
>      echo "</tr>\n<tr>\n";
>  }
> 
> (There are currently 8 pics that have been uploaded).  As you 
> can see that
> the first row has returned just two columns.  I'd like the 
> photos to be
> displayed in rows of three, and if there are only 8 pictures 
> (or any othe
> number that's not directly divisible by three) to be 
> displayed on the last
> row.   At the moment it's doing it "upside down."  Any ideas?
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 

Reply via email to