NYCPHP Meetup

[nycphp-talk] image display

selyah selyah1 at yahoo.com
Sun Aug 26 21:44:03 EDT 2007


yjanks, but that did not work, it created a 1 column table

Gary Mort <bz-gmort at beezifies.com> wrote: selyah wrote:
> could someone please look at this code and please tell me what is wrong.
> it is suppose to display a 4 column table with an indiffenate number 
> of rows.
> Instead it displays one image in row , then 3 images in row 2.  Then 
> one image in row 3 and e images in row 4, and so on.  thanks.

Your end table code is in the wrong place.
Here is what your code is doing:
$col is set to 0

Your loop begins
Checks $col to see if it is 0, it is so it starts a row
Image 1
Checks $col to see if it is 0, it is so it ends the row
increments $col to 1
Checks $col to see if it is 4, it isn't so it does nothing.
Image 2
Checks $col to see if it is 0, it is not
increments $col to 2
Checks $col to see if it is 4, it isn't so it does nothing.
Image 3
Checks $col to see if it is 0, it is not
increments $col to 3
Checks $col to see if it is 4, it isn't so it does nothing.
Image 4
Checks $col to see if it is 0, it is not
increments $col to 4
Checks $col to see if it is 4, it is so it sets $col to 0
Checks $col to see if it is 0, it is so it starts a row
Image 5
Checks $col to see if it is 0, it is so it ends the row
....

Your output is probably really strange, as follows:

image1
image2image3image4
image5
image6image7image8

Frankly, it's a matter of luck on how those non row cells get displayed.

Move if($col == 0)... to the end of the loop, after $col = ($col == 4) ? 
0 : $col; and you should be all good.

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070826/9d76b01a/attachment.html>


More information about the talk mailing list