forcom Posted June 7, 2009 Share Posted June 7, 2009 $ctryfrom = "SELECT DISTINCT country FROM table"; $ctry = mysql_query($ctryfrom); while($row = mysql_fetch_assoc($ctry)){ $countrynames = $row['country']; echo '<table><tr><td>'; echo "$countrynames"; //How can I set the loop to echo </td></tr><tr><td> ten loops to add another column in the table. } Quote Link to comment https://forums.phpfreaks.com/topic/161289-solved-how-to-echo-in-a-loop/ Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 You'll need a counter. <?php $ctryfrom = "SELECT DISTINCT country FROM table"; $ctry = mysql_query($ctryfrom); echo '<table><tr><td>'; $counter = 0; while($row = mysql_fetch_assoc($ctry)) { echo $row['country']; if (++$counter % 10 === 0) echo '</td></tr><tr><td>'; } echo '</td></tr></table>'; Quote Link to comment https://forums.phpfreaks.com/topic/161289-solved-how-to-echo-in-a-loop/#findComment-851100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.