455,642 Members | 1,672 Online
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

# Easy if....question

 P: n/a Hi!!!! I need to create a table of 4 columns x n rows. The number of row will depend on the number of images for that specific page. I think that I have to use de mod function saying that if (number of image mod 4 equal 0 then start another row) Well....first thing...I find the function fmod in the help that I think that will be useful. I wrote this small code, but it does not work while(\$row = mysql_fetch_array(\$respuesta)) { echo('
'); \$i++; if (fmod (\$i,4)==0) { } } Anyone can help me? Thanks in advance Ezequiel Jul 17 '05 #1
3 Replies

 P: n/a In article , es*******@hotmail.com (Eze) wrote: I think that I have to use de mod function saying that if (number of image mod 4 equal 0 then start another row) It seems simpler to me to just check if the number is equal to 4, and if it is, reset it to zero again. \$i = 0; while(\$row = mysql_fetch_array(\$respuesta)) { if (\$i < 4) { do_something(); \$i++; } elseif (\$i == 4) { do_something_else(); \$i = 0; } } JP -- Sorry, is een "spam trap". E-mail adres is , waarbij "at" = @. Jul 17 '05 #2

 P: n/a On 17-Apr-2004, es*******@hotmail.com (Eze) wrote: I need to create a table of 4 columns x n rows. The number of row will depend on the number of images for that specific page. I think that I have to use de mod function saying that if (number of image mod 4 equal 0 then start another row) Well....first thing...I find the function fmod in the help that I think that will be useful. I wrote this small code, but it does not work while(\$row = mysql_fetch_array(\$respuesta)) { echo('
'); \$i++; if (fmod (\$i,4)==0) { } } Anyone can help me? You have several problems. The fmod() or % will work, I find counting easier. Your HTML is wrong (spaces in the src= parm for example). The in the if needs an echo or something. This should be close (untested): echo ''; \$i = 0; while(\$row = mysql_fetch_array(\$respuesta)) { if (\$i==4) { echo ''; \$i=0; } echo ''; \$i++; } while(\$i<4) { echo ''; \$i++; } echo ''; -- Tom Thackrey www.creative-light.com tom (at) creative (dash) light (dot) com do NOT send email to ja*********@willglen.net (it's reserved for spammers) Jul 17 '05 #3

 P: n/a In message <7g******************@newssvr27.news.prodigy.com >, Tom Thackrey writesYou have several problems. The fmod() or % will work, I find countingeasier. Your HTML is wrong (spaces in the src= parm for example). The
in the if needs an echo or something.This should be close (untested):echo ''; echo ''; \$i = 0;while(\$row = mysql_fetch_array(\$respuesta)){ if (\$i==4) { echo ''; \$i=0; } echo ''; \$i++;}while(\$i<4){ echo ''; \$i++;}echo ''; -- Five Cats Email to: cats_spam at uk2 dot net Jul 17 '05 #4

### This discussion thread is closed

Replies have been disabled for this discussion.