* Thus wrote Terence Parker ([EMAIL PROTECTED]):
> How can I transfer the results above into an array such that I only need 
> to check $group_result->group_id against 
> $usergroup[$group_result->group_id] ?   <-- I know that won't work 
> syntactically, it's an example only.
> 
> Or is there a better way of doing this? Is there a function that merely 
> asks if an item (say, '6') exists in ALL the results above?

An alterative is get the data you need back from the database then
you just have one result to go through in php.


select ug.username, g.* 
  from groups g left join usergroup ug on (g.id = ug.group_id)
where ug.username = 'tparker';

+----------+---------------+
| username | g.id | g.name |
+----------+---------------+
| tparker  |    3 | group3 |
| tparker  |    6 | group6 |
| NULL     |    1 | group1 |


if (empty($result->username)) {
  // not in group
} else {
  // in group
}


Curt
-- 
"My PHP key is worn out"

  PHP List stats since 1997: 
    http://zirzow.dyndns.org/html/mlists/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to