Table looking odd as a result of while loop?

From: Date: Mon, 26 Feb 2001 21:54:59 +0000
Subject: Table looking odd as a result of while loop?
Groups: php.general 
Request: Send a blank email to php-general+get-41740@lists.php.net to get a copy of this message
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"; } echo "<td>$smallpic</td>\n"; $photocount++; } echo "</tr>\n"; echo "</table>"; and it's outputting a table like this: <table border="0"> <tr> <td>sm982438092.gif</td> <td>sm982437452.gif</td> </tr> <tr> <td>sm982439016.gif</td> <td>sm982529915.gif</td> <td>sm983222652.gif</td> </tr> <tr> <td>sm983222686.gif</td> <td>sm983222868.gif</td> <td>sm983222919.gif</td> </tr> </table> (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? And I know, I'm going to have to force an extra cell for it to display correctly.... Thanks as always, James.

« previous php.general (#41740) next »