markvaughn2006 Posted September 14, 2009 Share Posted September 14, 2009 I know this is simple, but all the while loop examples show you how to count to ten and then stop looping when it is greater than 10. I just need a while loop to display all data in a column and stop when it gets to the bottom. This is my jacked up attempt to display all usernames in the user_name column. Also how would I go about putting a <br> in between each echo? Thanks much! $result = mysql_query("SELECT user_name FROM users_tbl'") or die(mysql_error()); while $row = mysql_fetch_array( $result ); echo $row['user_name']; Link to comment https://forums.phpfreaks.com/topic/174256-while-loop-display-all-data-in-a-column/ Share on other sites More sharing options...
Mark Baker Posted September 14, 2009 Share Posted September 14, 2009 $result = mysql_query("SELECT user_name FROM users_tbl") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo $row['user_name']; echo '<br />'; } Link to comment https://forums.phpfreaks.com/topic/174256-while-loop-display-all-data-in-a-column/#findComment-918587 Share on other sites More sharing options...
kickstart Posted September 14, 2009 Share Posted September 14, 2009 Hi Assuming you mean one username per row (rather than a row having multiple user names which you want to split up):- $result = mysql_query("SELECT user_name FROM users_tbl'") or die(mysql_error()); while ($row = mysql_fetch_array( $result )) { echo $row['user_name'].'<br />'; } All the best Keith Link to comment https://forums.phpfreaks.com/topic/174256-while-loop-display-all-data-in-a-column/#findComment-918588 Share on other sites More sharing options...
markvaughn2006 Posted September 14, 2009 Author Share Posted September 14, 2009 awesome, thanks! Link to comment https://forums.phpfreaks.com/topic/174256-while-loop-display-all-data-in-a-column/#findComment-918602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.