shorty3 Posted May 13, 2010 Share Posted May 13, 2010 i have this code <? $query_friends=mysql_query("SELECT * FROM friends WHERE username='$viewuser' AND type='Friend'"); $rows=mysql_num_rows($query_friends); if ($rows == "0"){ echo "<center>No friends</center>"; } $friend = 0; while($dip=mysql_fetch_object($query_friends)){ echo ($friend % 3 == 0)? "<br>" : ""; echo " <a href='profile.php?viewuser=$dip->person'>$dip->person</a>,"; $friend++; } ?> at the moment this code will do a <br> at the start and at the end but i want it only at the end example what its doin now [table border=1] <- i dnt want the <br> here username, username, username username, username, username this is what i want [table border=1] username, username, username username, username, username If This Dont Make Sense Then I Dont No What To Do Because The Table On This Doesnt Show Up Link to comment https://forums.phpfreaks.com/topic/201660-array-difficulties/ Share on other sites More sharing options...
shorty3 Posted May 13, 2010 Author Share Posted May 13, 2010 1 Link to comment https://forums.phpfreaks.com/topic/201660-array-difficulties/#findComment-1057867 Share on other sites More sharing options...
kenrbnsn Posted May 13, 2010 Share Posted May 13, 2010 Move the echo statement after the counter is incremented: <?php while($dip=mysql_fetch_object($query_friends)){ echo " <a href='profile.php?viewuser=$dip->person'>$dip->person</a>,"; $friend++; echo ($friend % 3 == 0)? "<br>" : ""; } ?> Ken Link to comment https://forums.phpfreaks.com/topic/201660-array-difficulties/#findComment-1057873 Share on other sites More sharing options...
shorty3 Posted May 13, 2010 Author Share Posted May 13, 2010 You Legend i should of knew that though Link to comment https://forums.phpfreaks.com/topic/201660-array-difficulties/#findComment-1057875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.