[PHP] while loop and modulus?

2001-02-27 Thread James, Yz

OK, using this code:

?

echo "table border=\"0\"\n";
echo "tr\n";

$photocount = 0;

while($row = mysql_fetch_array($result)) {
 $smallpic = $row['smallpic'];

 echo "td$smallpic/td\n";

 if (($photocount % 3) == 2) {
 echo "/tr\ntr\n";
 }
 $photocount++;

 }

echo "/tr\n";
echo "/table";

?

And 8 photos in the table, I'm getting this output:

table border="0"
tr
tdsm982438092.gif/td
tdsm982437452.gif/td
tdsm982439016.gif/td
/tr
tr
tdsm982529915.gif/td
tdsm983222652.gif/td
tdsm983222686.gif/td
/tr
tr
tdsm983222868.gif/td
tdsm983222919.gif/td
/tr
/table

Great, except it's missing an end cell, and after a few hours fiddling about
with code last night, I still didn't get any further in working out how I
was going to echo a table cell even if data's missing.  So, any help would
be appreciated.

Apologies for what're probably "easy" questions.  I slog away at work all
day, come back hoping to get something productive done on this, and the
ol'brain won't take it.  Frustrating, to say the least.

James.



-- 
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]




RE: [PHP] while loop and modulus?

2001-02-27 Thread DanO


by default, HTML browsers, according to spec, will handle the rendering of
any and all empty cells at the end of a row.

even netscape  ;)

so, this is technically not a bug.

my question is how it works when you have 7 photos in a row, or 4?

DanO



-Original Message-
From: James, Yz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 27, 2001 11:18 AM
To: [EMAIL PROTECTED]
Subject: [PHP] while loop and modulus?


OK, using this code:

?

echo "table border=\"0\"\n";
echo "tr\n";

$photocount = 0;

while($row = mysql_fetch_array($result)) {
 $smallpic = $row['smallpic'];

 echo "td$smallpic/td\n";

 if (($photocount % 3) == 2) {
 echo "/tr\ntr\n";
 }
 $photocount++;

 }

echo "/tr\n";
echo "/table";

?

And 8 photos in the table, I'm getting this output:

table border="0"
tr
tdsm982438092.gif/td
tdsm982437452.gif/td
tdsm982439016.gif/td
/tr
tr
tdsm982529915.gif/td
tdsm983222652.gif/td
tdsm983222686.gif/td
/tr
tr
tdsm983222868.gif/td
tdsm983222919.gif/td
/tr
/table

Great, except it's missing an end cell, and after a few hours fiddling about
with code last night, I still didn't get any further in working out how I
was going to echo a table cell even if data's missing.  So, any help would
be appreciated.

Apologies for what're probably "easy" questions.  I slog away at work all
day, come back hoping to get something productive done on this, and the
ol'brain won't take it.  Frustrating, to say the least.

James.



--
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]


-- 
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]