RE: [PHP] Table looking odd as a result of while loop?

From: Date: Mon, 26 Feb 2001 22:10:00 +0000
Subject: RE: [PHP] Table looking odd as a result of while loop?
Groups: php.general 
Request: Send a blank email to php-general+get-41744@lists.php.net to get a copy of this message
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:kjohnson@zootweb.com] > Sent: Monday, February 26, 2001 1:57 PM > To: php-general@lists.php.net > 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:liljim@btconnect.com] > Sent: Monday, February 26, 2001 2:55 PM > To: php-general@lists.php.net > 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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.general (#41744) next »