I am trying to make the list elements ($user_id, $user_username,) global so i can acccess them in the rest of my code further down in the page.
How do you take the elements of an array and make them global?
here is the code:$resultID = mysql_query("Select * from user_access", $linkID);
while (list ($user_id, $user_username, $user_password, $user_fname, $user_lname, $user_access, $user_email) = mysql_fetch_row($resultID))
{
}
making "list" vars global
Moderator: General Moderators
-
daholygoat
- Forum Newbie
- Posts: 1
- Joined: Thu May 16, 2002 4:42 pm
Well there's a bit more to it. When you're using the list() inside the while(), logically the variables get re-initiated after every loop sequence, thus they will be lost at the end of the block anyway. What you could do however is creating an array before the loop, and read the seperate variables that are a result from list() into the array while looping. That way the array is filled after the loop invoked.
- sam
- Forum Contributor
- Posts: 217
- Joined: Thu Apr 18, 2002 11:11 pm
- Location: Northern California
- Contact:
Code: Select all
$i = 0;
while (list ($user_idї$i], $user_usernameї$i], $user_passwordї$i], $user_fnameї$i], $user_lnameї$i], $user_accessї$i], $user_emailї$i]) = mysql_fetch_row($resultID)){
$i++;
}