On 01 October 2008 21:24, tedd advised: > At 2:38 PM -0500 10/1/08, Afan Pasalic wrote: >> main reason - if you sort by first or last name you will lose "index". >> this way is index always "linked" to first/last name. > > Your point is well taken, but I'm not sorting this. > > True, the arrays have a common index, which is 0, 1, 2, 3 ... > > [user_id] => Array > ( > [0] => 6156 > [1] => 7030 > [2] => 656 > ) > > [first_name] => Array > ( > [0] => Diane > [1] => Fred > [2] => Helen > ) > > [last_name] => Array > ( > [0] => Cable > [1] => Cago > [2] => Cahalan > > But the data is relational, such as: > > Diane Cable has user id 6156. > > I collected the data like this (in a loop): > > $_SESSION['user_id'][] = $value; > $_SESSION['first_name'][] = $first_name; > $_SESSION['last_name'][] = $last_name; > > Doing this is fine -- the index is automatic. > > I thought I could retrieve the data by using: > > $num_users = count($_SESSION['user_id']); // <--- this works (correct > $num_users) > > for ($i = 0; $i < $num_users; $i++) > { > $last_name = $_SESSION['last_name'][$i]; > $first_name = $_SESSION['first_name'][$i]; > echo("<tr><td>$last_name</td><td>$first_name</td></tr>"); } > > But that doesn't work. What's really odd is only the first loop works. I'm thinking register_globals here. In every example you've posted, you've used $last_name and $_SESSION['last_name'] -- but these are the same thing if register_globals is on, and would lead to your posted output with the single characters on the 2nd iteration and nothing after that! At least one posted suggestion used $first and $last rather than $first_name and $last_name -- did you actually try with the shorter names, or stick with your longer matching ones? Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.ford@xxxxxxxxxxxxxx Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php