Merdok Posted March 6, 2010 Share Posted March 6, 2010 I'm sure this is easy guys and its just a case of me not getting my head around it properly. I have a function which takes a list of space seperated twitter names and will return a feed for each user. It works really well but I want to modify it slightly. currently it works like this: $usernames = "username1 username2 username3"; The space is the seperator. So I figured it would be easy enough to pull a list of the site admins with twitter accounts and list them in this fashion so I did this: $twitterAuthors = mysql_query("SELECT usr_twitter FROM core_users WHERE usr_access_lvl <=4"); while(list($usr_twitter) = mysql_fetch_array($twitterAuthors, MYSQL_NUM)) { $twits = $usr_twitter.' '; } Now this works and creates the space seperated list of twitter users but I can't work out how to use it outside of the while loop, it only returns the last result. Obvously I cant put the twitter function into the loop as it will repeat the whole thing and that isn't what I want. I'm sure this is easy but I've never had to use looped values outside of the loop before so I'm unsure of what to do. Link to comment https://forums.phpfreaks.com/topic/194333-pull-out-a-looped-list-a-values-from-the-database-to-use-outside-the-loop/ Share on other sites More sharing options...
Goat Posted March 6, 2010 Share Posted March 6, 2010 try: $twits .= $usr_twitter.' '; The .= there means that php will ADD new value to existing not delete old and put new in place. Goat Link to comment https://forums.phpfreaks.com/topic/194333-pull-out-a-looped-list-a-values-from-the-database-to-use-outside-the-loop/#findComment-1022311 Share on other sites More sharing options...
Merdok Posted March 6, 2010 Author Share Posted March 6, 2010 tsk of course! Thank you so much Link to comment https://forums.phpfreaks.com/topic/194333-pull-out-a-looped-list-a-values-from-the-database-to-use-outside-the-loop/#findComment-1022321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.