Jump to content


Photo

While loop question


  • Please log in to reply
3 replies to this topic

#1 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 28 August 2006 - 05:50 PM

I am looping through results of locations and need to display them in a table, two columns arcoss then have it go to the next row. I am not sure how to do that though?

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 28 August 2006 - 05:58 PM

$i=1;
echo '<table width="200" border="0" cellpadding="0" cellspacing="0">';
while ($num < 10) {
 if ($i == 1) {
  echo '<tr>';
 }
 elseif ($i == 3) {
  echo '</tr>';
  $i=1;
 }
 echo '<td>$location</td>';
 $i++;
}
echo '</table>';


i think that should work :)

Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 28 August 2006 - 11:17 PM

Doesn't seem to work, it just keeps looping without stoping.

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 28 August 2006 - 11:29 PM

With slight modification I've got it to work. Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users