Jump to content

Pull out a looped list a values from the database to use outside the loop


Merdok

Recommended Posts

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.